<template>
  <div style="display: flex; width: 100%" ref="box">
    <div class="leftBox" ref="leftBox" :style="leftBoxStyle">
      <div
        style="
          text-align: center;
          font-family: 'Arial Negreta', 'Arial Normal', 'Arial', sans-serif;
          font-weight: 700;
          font-style: normal;
          font-size: 16px;
        "
      >
        药历
      </div>
      <el-collapse v-model="activeCard" @change="handleChange">
        <el-collapse-item title="入院药学评估" name="1">
          <RuYuanPingGu :getYaoLiShouYeList="getYaoLiShouYeList"/>
        </el-collapse-item>
        <el-collapse-item title="药历首页" name="2">
          <div
            style="padding: 10px 10px; border: 1px solid rgba(242, 242, 242, 1)"
          >
            <el-form
              ref="form"
              :model="form"
              label-width="100px"
              label-position="left"
              v-loading="dataloading"
            >
              <div class="r">
                <el-row :gutter="40">
                  <el-col :span="12">
                    <el-form-item
                      label="病区"
                      prop="deptId"
                      style="width: 100%"
                    >
                      <treeselect
                        v-model="form.patientBaseInfoVo.deptId"
                        :options="deptOptions"
                        :show-count="true"
                        placeholder="请选择科室/病区"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="流水号" prop="medicalRecordNo">
                      <el-input
                        disabled
                        v-model="form.patientBaseInfoVo.medicalRecordNo"
                        placeholder="请输入流水号"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
              </div>
              <el-row :gutter="40">
                <el-col :span="12">
                  <el-form-item label="床号" prop="bedNo">
                    <el-input
                      v-model="form.patientBaseInfoVo.bedNo"
                      placeholder="请输入床号"
                      clearable
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="病案号" prop="medicareNo">
                    <el-input
                      disabled
                      v-model="form.patientBaseInfoVo.medicareNo"
                      placeholder="请输入病案号"
                    />
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="40">
                <el-col :span="12">
                  <el-form-item label="姓名" prop="patientName">
                    <el-input
                      v-model="form.patientBaseInfoVo.patientName"
                      placeholder="请输入患者姓名"
                      clearable
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="联系方式" prop="phoneNo">
                    <el-input
                      v-model="form.patientBaseInfoVo.phoneNo"
                      placeholder="请输入联系方式"
                      clearable
                    />
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="40">
                <el-col :span="12">
                  <el-form-item label="ID号" prop="patientNo">
                    <el-input
                      v-model="form.patientBaseInfoVo.patientNo"
                      placeholder="请输入ID号"
                      clearable
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="性别" prop="patientSex">
                    <el-select
                      v-model="form.patientBaseInfoVo.patientSex"
                      placeholder="请选择"
                      clearable
                      :style="{ width: '100%' }"
                    >
                      <el-option
                        v-for="(item, index) in userSex"
                        :key="index"
                        :label="item.dictLabel"
                        :value="item.dictValue"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="40">
                <el-col :span="12">
                  <el-form-item
                    label="年龄"
                    prop="patientAge"
                    :error="errormsg1"
                  >
                    <el-input
                      v-if="year == 1"
                      clearable
                      v-model="form.patientBaseInfoVo.patientAge"
                      placeholder="请输入年龄"
                      @input="input1"
                    >
                      <el-select
                        v-model="year"
                        slot="append"
                        placeholder="请选择"
                        style="width: 70px"
                        @change="ChangeYear"
                      >
                        <el-option label="岁" value="1"></el-option>
                        <el-option label="月" value="2"></el-option>
                      </el-select>
                    </el-input>
                    <el-input
                      v-else
                      v-model="form.patientBaseInfoVo.patientMonth"
                      placeholder="请输入月份"
                      clearable
                      @input="input2"
                    >
                      <el-select
                        v-model="year"
                        slot="append"
                        placeholder="请选择"
                        style="width: 70px"
                        @change="ChangeYear"
                      >
                        <el-option label="岁" value="1"></el-option>
                        <el-option label="月" value="2"></el-option>
                      </el-select>
                    </el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="出生日期" prop="birthdate">
                    <el-input
                      disabled
                      v-model="form.patientBaseInfoVo.birthdate"
                      placeholder="请输入出生日期"
                      @keyup.enter.native="submitForm"
                    />
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="40">
                <el-col :span="12">
                  <el-form-item label="职业" prop="patientProfession">
                    <el-input
                      v-model="form.patientBaseInfoVo.patientProfession"
                      placeholder="请输入职业"
                      clearable
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="民族" prop="nation">
                    <el-input
                      v-model="form.patientBaseInfoVo.nation"
                      placeholder="请输入民族"
                      clearable
                    />
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="40">
                <el-col :span="12">
                  <el-form-item label="身高 (cm)" prop="patientHeight">
                    <el-input
                      v-model="form.patientBaseInfoVo.patientHeight"
                      placeholder="请输入身高"
                      @focus="handleBmi"
                      @input="handleBmi"
                      clearable
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="体重 (kg)" prop="patientWeight">
                    <el-input
                      v-model="form.patientBaseInfoVo.patientWeight"
                      placeholder="请输入体重"
                      @focus="handleBmi"
                      @input="handleBmi"
                      clearable
                    />
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="40">
                <el-col :span="12">
                  <el-form-item label="BMI (kg/m²)" prop="patientBmi">
                    <el-input
                      v-model="form.patientBaseInfoVo.patientBmi"
                      placeholder="请输入BMI"
                      clearable
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="费别" prop="payWay">
                    <el-select
                      v-model="form.patientBaseInfoVo.payWay"
                      placeholder="请选择费别"
                      clearable
                      :style="{ width: '100%' }"
                    >
                      <el-option
                        v-for="(item, index) in payWay"
                        :key="index"
                        :label="item.dictLabel"
                        :value="item.dictValue"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="40">
                <el-col :span="12">
                  <el-form-item label="监护分级" prop="guardianLevel">
                    <el-select
                      v-model="form.patientBaseInfoVo.guardianLevel"
                      placeholder="请选择监护分级"
                      clearable
                      :style="{ width: '100%' }"
                    >
                      <el-option
                        v-for="(item, index) in guardianLevel"
                        :key="index"
                        :label="item.dictLabel"
                        :value="item.dictValue"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-form-item label="主诉：" prop="selfReported">
                <el-input
                  type="textarea"
                  autosize
                  placeholder="请输入内容"
                  v-model="form.selfReported"
                />
              </el-form-item>
              <el-form-item label="不良嗜好：" prop="isHaveBadHobby">
                <el-radio-group
                  v-model="form.isHaveBadHobby"
                  @change="handleisHaveBadHobby"
                >
                  <el-radio :label="'0'">无</el-radio>
                  <el-radio :label="'1'">有</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item
                v-show="form.isHaveBadHobby == 1"
                label=""
                prop="isWine"
              >
                <div class="r buliangshihao">
                  <div class="r">
                    <el-radio
                      v-model="form.isWine"
                      :label="'1'"
                      @click.prevent.native="handleisWine(form.isWine)"
                    >酒
                    </el-radio
                    >
                    <div class="r" style="margin-right: 8px">
                      <el-input
                        style="width: 80px"
                        v-model="form.wineYear"
                        placeholder=""
                      />
                      <span class="ml5">年</span>
                    </div>
                    <div class="r">
                      <el-input
                        style="width: 80px; height: 30px"
                        v-model="form.wineAmountPerDay"
                        placeholder=""
                      />
                      <span class="ml5">两/天</span>
                    </div>
                  </div>
                  <div class="ml80">
                    <el-radio
                      v-model="form.isSmoke"
                      :label="'1'"
                      @click.prevent.native="handleisSmoke(form.isSmoke)"
                    >烟
                    </el-radio>
                    <div style="display: inline-block; margin-right: 8px">
                      <el-input
                        style="width: 80px"
                        v-model="form.smokeYear"
                        placeholder=""
                      />
                      <span class="ml5 mr5">年</span>
                      <el-input
                        style="width: 80px"
                        v-model="form.smokeAmountPerDay"
                        placeholder=""
                      />
                      <span class="ml5">支/天</span>
                    </div>
                  </div>
                </div>
              </el-form-item>
              <el-form-item
                v-show="form.isHaveBadHobby == 1"
                label=""
                prop="isEat"
              >
                <div style="display: inline-block">
                  <el-radio
                    v-model="form.isEat"
                    :label="'1'"
                    @click.prevent.native="handleisEat(form.isEat)"
                  >饮食
                  </el-radio
                  >
                  <div class="buliangshihao" style="display: inline-block">
                    <el-input
                      style="width: 285px"
                      v-model="form.eatBadHobby"
                      placeholder=""
                    />
                  </div>
                </div>
                <div style="display: inline-block; margin-left: 5px">
                  <el-radio
                    v-model="form.isOther"
                    :label="'1'"
                    @click.prevent.native="handleisOther(form.isOther)"
                  >其他
                  </el-radio
                  >
                  <div class="buliangshihao" style="display: inline-block">
                    <el-input
                      style="width: 285px"
                      v-model="form.otherBadHobby"
                      placeholder=""
                    />
                  </div>
                </div>
              </el-form-item>
              <el-form-item label="现病史：" prop="isHaveMedicalHistoryNow">
                <el-input
                  type="textarea"
                  autosize
                  placeholder="请输入内容"
                  v-model="form.medicalHistoryNow"
                />
              </el-form-item>
              <el-form-item
                label="现病史用药汇总："
                prop="nowMedicalRecordVoList"
              >
                <el-radio-group v-model="form.medicationSummaryOption1">
                  <el-radio :label="true">有</el-radio>
                  <el-radio :label="false">无</el-radio>
                </el-radio-group>
                <el-button
                  v-if="form.medicationSummaryOption1 == true"
                  style="
                    float: right;
                    background-color: #b8dfea;
                    margin-bottom: 10px;
                  "
                  @click="addNowMedicalRecordList"
                >添加一行
                </el-button
                >
                <el-table
                  v-if="form.medicationSummaryOption1 == true"
                  :border="true"
                  :data="form.nowMedicalRecordVoList"
                  key="nowMedicalRecordVoList"
                  style="width: 100%"
                >
                  <el-table-column
                    prop="purpose"
                    label="原发病"
                    min-width="150"
                    fixed
                    align="center"
                  >
                    <template slot-scope="scope">
                      <el-input
                        class="require_des"
                        v-model="scope.row.purpose"
                      ></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="pillsName"
                    label="药物名称"
                    min-width="300"
                    fixed
                    align="center"
                  >
                    <template slot-scope="scope">
                      <el-autocomplete
                        style="width: 100%"
                        class="require_des"
                        v-model="scope.row.pillsName"
                        :fetch-suggestions="querySearchAsync"
                        @select="handleSelect"
                      >
                        <template slot-scope="{ item }">
                          <el-tooltip
                            class="item"
                            effect="dark"
                            :content="item.value"
                            placement="right-end"
                          >
                            <div
                              class="query-item-text"
                              style="
                                overflow: hidden;
                                text-overflow: ellipsis;
                                white-space: nowrap;
                              "
                            >
                              {{ item.value }}
                            </div>
                          </el-tooltip>
                        </template>
                      </el-autocomplete
                      >
                    </template>
                  </el-table-column>
                  <el-table-column
                    align="center"
                    prop="amount"
                    label="用法用量"
                    min-width="150"
                    fixed
                  >
                    <template slot-scope="scope">
                      <el-input
                        class="require_des"
                        v-model="scope.row.amount"
                      ></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="pillsCycle"
                    label="最后用药时间"
                    align="center"
                    width="190"
                  >
                    <template slot-scope="scope">
                      <el-input
                        class="require_des"
                        v-model="scope.row.pillsCycle"
                      ></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="isContinue"
                    label="是否继续使用"
                    width="111"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <el-radio-group v-model="scope.row.isContinue">
                        <el-radio :label="'Y'">是</el-radio>
                        <el-radio :label="'N'">否</el-radio>
                      </el-radio-group>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="操作"
                    width="130"
                    align="center"
                    fixed="right"
                  >
                    <template slot-scope="scope">
                      <el-button
                        v-if="scope.$index > 0"
                        type="text"
                        size="small"
                        @click="moveUp(scope.row, scope.$index, 1)"
                      >
                        上移
                      </el-button>
                      <el-button
                        v-if="
                          scope.$index < form.nowMedicalRecordVoList.length - 1
                        "
                        type="text"
                        size="small"
                        @click="moveDown(scope.row, scope.$index, 1)"
                      >
                        下移
                      </el-button>
                      <el-button
                        type="text"
                        size="small"
                        @click="
                          delNowMedicalRecordVoList(scope.row, scope.$index)
                        "
                      >删除
                      </el-button
                      >
                    </template>
                  </el-table-column>
                </el-table>
              </el-form-item>
              <el-form-item label="既往病史：" prop="medicalHistoryBefore">
                <el-input
                  type="textarea"
                  :rows="4"
                  placeholder="请输入内容"
                  v-model="form.medicalHistoryBefore"
                />
              </el-form-item>
              <el-form-item
                label="既往病史用药汇总："
                prop="beforeMedicalRecordVoList"
              >
                <el-radio-group v-model="form.medicationSummaryOption2">
                  <el-radio :label="true">有</el-radio>
                  <el-radio :label="false">无</el-radio>
                </el-radio-group>
                <el-button
                  v-if="form.medicationSummaryOption2 == true"
                  style="
                    background-color: #b8dfea;
                    margin-bottom: 10px;
                    float: right;
                  "
                  @click="addbeforeMedicalRecordList"
                >添加一行
                </el-button
                >
                <el-table
                  v-if="form.medicationSummaryOption2 == true"
                  :border="true"
                  key="beforeMedicalRecordVoList"
                  :data="form.beforeMedicalRecordVoList"
                  style="width: 100%"
                >
                  <el-table-column
                    prop="purpose"
                    label="原发病"
                    min-width="150"
                    fixed
                    align="center"
                  >
                    <template slot-scope="scope">
                      <el-input
                        class="require_des"
                        v-model="scope.row.purpose"
                      ></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="pillsName"
                    label="药物名称"
                    min-width="300"
                    fixed
                    align="center"
                  >
                    <template slot-scope="scope">
                      <el-autocomplete
                        style="width: 100%"
                        class="require_des"
                        v-model="scope.row.pillsName"
                        :fetch-suggestions="querySearchAsync"
                        @select="handleSelect"
                      >
                        <template slot-scope="{ item }">
                          <el-tooltip
                            class="item"
                            effect="dark"
                            :content="item.value"
                            placement="right-end"
                          >
                            <div
                              class="query-item-text"
                              style="
                                overflow: hidden;
                                text-overflow: ellipsis;
                                white-space: nowrap;
                              "
                            >
                              {{ item.value }}
                            </div>
                          </el-tooltip>
                        </template>
                      </el-autocomplete
                      >
                    </template>
                  </el-table-column>
                  <el-table-column
                    align="center"
                    prop="amount"
                    label="用法用量"
                    min-width="150"
                    fixed
                  >
                    <template slot-scope="scope">
                      <el-input
                        class="require_des"
                        v-model="scope.row.amount"
                      ></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="pillsCycle"
                    label="最后用药时间"
                    align="center"
                    width="190"
                  >
                    <template slot-scope="scope">
                      <el-input
                        class="require_des"
                        v-model="scope.row.pillsCycle"
                      ></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="isContinue"
                    label="是否继续使用"
                    width="111"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <el-radio-group v-model="scope.row.isContinue">
                        <el-radio :label="'Y'">是</el-radio>
                        <el-radio :label="'N'">否</el-radio>
                      </el-radio-group>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="操作"
                    width="130"
                    align="center"
                    fixed="right"
                  >
                    <template slot-scope="scope">
                      <el-button
                        v-if="scope.$index > 0"
                        type="text"
                        size="small"
                        @click="moveUp(scope.row, scope.$index, 2)"
                      >
                        上移
                      </el-button>
                      <el-button
                        v-if="
                          scope.$index <
                          form.beforeMedicalRecordVoList.length - 1
                        "
                        type="text"
                        size="small"
                        @click="moveDown(scope.row, scope.$index, 2)"
                      >
                        下移
                      </el-button>
                      <el-button
                        type="text"
                        size="small"
                        @click="
                          delBeforeMedicalRecordVoList(scope.row, scope.$index)
                        "
                      >删除
                      </el-button
                      >
                    </template>
                  </el-table-column>
                </el-table>
              </el-form-item>
              <el-form-item
                label="过敏史及处置史："
                label-width="130px"
                prop="isHaveAllergy"
              >
                <el-radio-group
                  v-model="form.isHaveAllergy"
                  @change="handleisHaveAllergy"
                >
                  <el-radio :label="'0'">无</el-radio>
                  <el-radio :label="'1'">有</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item
                v-show="form.isHaveAllergy == 1"
                label=""
                prop="isHaveAllergy"
              >
                <div class="buliangshihao">
                  <div class="r">
                    <span class="mr10">怀疑药物/食物名称</span>
                    <el-input
                      style="width: 250px"
                      v-model="form.doubtPillsOrFoodName"
                      placeholder=""
                    />
                  </div>
                  <div class="r mb10">
                    <span class="mr10">主要ADR临床表现</span>
                    <el-input
                      style="width: 250px"
                      v-model="form.adrClinicFeature"
                      placeholder=""
                    />
                  </div>
                  <div class="r">
                    <span style="display: inline-block; width: 190px"
                    >处理措施及结果</span
                    >
                    <el-checkbox-group v-model="form.disposeAndResult" :max="1">
                      <el-row>
                        <el-col
                          :span="8"
                          v-for="item in disposeResult"
                          :key="item.id"
                        >
                          <el-checkbox
                            style="font-size: 13px"
                            :label="item.dictValue"
                            :key="item.id"
                            class="region-list-item"
                          >{{ item.dictLabel }}
                          </el-checkbox
                          >
                        </el-col>
                      </el-row>
                    </el-checkbox-group>
                  </div>
                  <div class="r">
                    <el-radio
                      class="mr10"
                      v-model="form.isOtherDisposeAndResult"
                      @click.prevent.native="
                        handleisOtherDisposeAndResult(
                          form.isOtherDisposeAndResult
                        )
                      "
                      :label="'1'"
                    >其他
                    </el-radio
                    >
                    <el-input
                      style="width: 250px"
                      v-model="form.otherDisposeAndResult"
                      placeholder=""
                    />
                  </div>
                </div>
              </el-form-item>
              <el-form-item label="家族史：" prop="familyHistory">
                <el-input
                  type="textarea"
                  :rows="4"
                  placeholder="请输入内容"
                  v-model="form.familyHistory"
                />
              </el-form-item>
              <el-form-item label="个人史：" prop="personHistory">
                <el-input
                  type="textarea"
                  :rows="4"
                  placeholder="请输入内容"
                  v-model="form.personHistory"
                />
              </el-form-item>
              <el-form-item label="入院诊断：" prop="admittingDiagnosisWestern">
                <div>西医诊断</div>
                <el-input
                  type="textarea"
                  :rows="4"
                  placeholder="请输入内容"
                  v-model="form.admittingDiagnosisWestern"
                />
                <div class="r" style="justify-content: space-between">
                  <div class="mr20">中医诊断</div>
                  <el-button
                    style="background-color: #b8dfea; margin: 10px 0px"
                    @click="addTraditionalDiagnosisVoList(0)"
                  >添加一行
                  </el-button
                  >
                </div>
                <el-table
                  :border="true"
                  :data="form.traditionalDiagnosisVoList"
                  key="traditionalDiagnosisVoList"
                  style="width: 100%"
                >
                  <el-table-column
                    prop="illnessName"
                    label="病"
                    width=""
                    align="center"
                  >
                    <template slot-scope="scope">
                      <el-input
                        class="require_des"
                        v-model="scope.row.illnessName"
                      ></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="patternOfSyndrome"
                    label="证型"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <el-input
                        class="require_des"
                        v-model="scope.row.patternOfSyndrome"
                      ></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="address"
                    label="操作"
                    width="60"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <el-button
                        type="text"
                        size="small"
                        @click="
                          delTraditionalDiagnosisVoList(
                            scope.row,
                            scope.$index,
                            0
                          )
                        "
                      >删除
                      </el-button
                      >
                    </template>
                  </el-table-column>
                </el-table>
              </el-form-item>
              <el-form-item
                label="初始药物诊疗方案汇总："
                prop="initalMedicalRecordVoList"
              >
                <div style="float: right">
                  <el-button
                    style="margin-bottom: 10px"
                    type="primary"
                    @click="getHISdirLog(2)"
                  >查询HIS医嘱用药
                  </el-button
                  >
                  <el-button
                    style="
                      background-color: #b8dfea;
                      margin-bottom: 10px;
                      float: right;
                    "
                    @click="addMedicalRecordBoList(2)"
                  >添加一行
                  </el-button
                  >
                </div>
                <el-table
                  class="chushiyaowuzhenliao"
                  :data="form.initalMedicalRecordVoList"
                  key="initalMedicalRecordVoList"
                  :cell-class-name="isRender"
                  ref="multipleTable2"
                  border
                >
                  <el-table-column
                    prop="pillsName"
                    label="药物名称"
                    min-width="300"
                    fixed
                    align="center"
                    style="display: flex; align-items: center"
                  >
                    <template slot-scope="scope">
                      <el-autocomplete
                        style="width: 100%"
                        class="require_des"
                        v-model="scope.row.pillsName"
                        :fetch-suggestions="querySearchAsync"
                        @select="handleSelect"
                      >
                        <template slot-scope="{ item }">
                          <el-tooltip
                            class="item"
                            effect="dark"
                            :content="item.value"
                            placement="right-end"
                          >
                            <div
                              class="query-item-text"
                              style="
                                overflow: hidden;
                                text-overflow: ellipsis;
                                white-space: nowrap;
                              "
                            >
                              {{ item.value }}
                            </div>
                          </el-tooltip>
                        </template>
                      </el-autocomplete
                      >
                    </template>
                  </el-table-column>
                  <el-table-column
                    align="center"
                    prop="amountPer"
                    label="单次剂量"
                    fixed
                    min-width="100"
                  >
                    <template slot-scope="scope">
                      <el-input
                        class="require_des"
                        v-model="scope.row.amountPer"
                      ></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    align="center"
                    prop="pillsUsage"
                    label="用法"
                    min-width="100"
                  >
                    <template slot-scope="scope">
                      <el-input
                        class="require_des"
                        v-model="scope.row.pillsUsage"
                      ></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    align="center"
                    prop="frequency"
                    label="频次"
                    min-width="100"
                  >
                    <template slot-scope="scope">
                      <el-input
                        class="require_des"
                        v-model="scope.row.frequency"
                      ></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="beginDate"
                    label="起始日期"
                    align="center"
                    width="190"
                  >
                    <template slot-scope="scope">
                      <el-date-picker
                        v-model="scope.row.beginDate"
                        type="datetime"
                        clearable
                        format="yyyy-MM-dd"
                        value-format="yyyy-MM-dd HH:mm"
                        placeholder="请选择起始日期"
                        :picker-options="pickerOptions"
                        :disabledDate="disabledDate"
                      >
                      </el-date-picker>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="操作"
                    width="130"
                    fixed="right"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <el-button
                        v-if="scope.$index > 0"
                        type="text"
                        size="small"
                        @click="moveUp(scope.row, scope.$index, 3)"
                      >
                        上移
                      </el-button>
                      <el-button
                        v-if="
                          scope.$index <
                          form.initalMedicalRecordVoList.length - 1
                        "
                        type="text"
                        size="small"
                        @click="moveDown(scope.row, scope.$index, 3)"
                      >
                        下移
                      </el-button>
                      <el-button
                        type="text"
                        size="small"
                        @click="
                          delMedicalRecordBoList(scope.row, scope.$index, 2)
                        "
                      >删除
                      </el-button
                      >
                    </template>
                  </el-table-column>
                </el-table>
                <el-table
                  v-if="false"
                  :border="true"
                  :data="form.initalMedicalRecordVoList"
                  key="initalMedicalRecordVoList"
                  style="width: 100%"
                >
                  <el-table-column
                    prop="purpose"
                    label="用药目的"
                    width="80"
                    fixed
                    align="center"
                  >
                    <template slot-scope="scope">
                      <el-input
                        class="require_des"
                        v-model="scope.row.purpose"
                      ></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="pillsName"
                    label="药物名称"
                    width="250"
                    fixed
                    align="center"
                  >
                    <template slot-scope="scope">
                      <el-autocomplete
                        class="require_des"
                        v-model="scope.row.pillsName"
                        :fetch-suggestions="querySearchAsync"
                        @select="handleSelect"
                      >
                        <template slot-scope="{ item }">
                          <el-tooltip
                            class="item"
                            effect="dark"
                            :content="item.value"
                            placement="right-end"
                          >
                            <div
                              class="query-item-text"
                              style="
                                width: 170px;
                                overflow: hidden;
                                text-overflow: ellipsis;
                                white-space: nowrap;
                              "
                            >
                              {{ item.value }}
                            </div>
                          </el-tooltip>
                        </template>
                      </el-autocomplete
                      >
                    </template>
                  </el-table-column>
                  <el-table-column
                    align="center"
                    prop="amountPer"
                    label="单次剂量"
                    width="100"
                    fixed
                  >
                    <template slot-scope="scope">
                      <el-input
                        class="require_des"
                        v-model="scope.row.amountPer"
                      ></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    align="center"
                    prop="pillsUsage"
                    label="用法"
                    width="100"
                  >
                    <template slot-scope="scope">
                      <el-input
                        class="require_des"
                        v-model="scope.row.pillsUsage"
                      ></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    align="center"
                    prop="frequency"
                    label="频次"
                    width="100"
                  >
                    <template slot-scope="scope">
                      <el-input
                        class="require_des"
                        v-model="scope.row.frequency"
                      ></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="beginDate"
                    label="起始日期"
                    align="center"
                    width="130"
                  >
                    <template slot-scope="scope">
                      <el-date-picker
                        v-model="scope.row.beginDate"
                        type="datetime"
                        clearable
                        format="yyyy-MM-dd HH:mm"
                        value-format="yyyy-MM-dd HH:mm"
                        placeholder="请选择起始日期"
                        :picker-options="pickerOptions"
                        :disabledDate="disabledDate"
                      >
                      </el-date-picker>
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="address"
                    label="操作"
                    width="47"
                    align="center"
                    fixed="right"
                  >
                    <template slot-scope="scope">
                      <el-button
                        type="text"
                        size="small"
                        @click="
                          delMedicalRecordBoList(scope.row, scope.$index, 2)
                        "
                      >删除
                      </el-button
                      >
                    </template>
                  </el-table-column>
                </el-table>
              </el-form-item>

              <el-form-item label="" prop="initTraditionalMedicalList">
                <div class="r" style="justify-content: space-between">
                  <span></span>
                  <div>
                    <el-button
                      style="margin-bottom: 10px"
                      type="primary"
                      @click="getHISdirLog(5)"
                    >查询HIS中药饮片
                    </el-button
                    >
                    <el-button
                      style="
                        background-color: #b8dfea;
                        margin-bottom: 10px;
                        float: right;
                      "
                      @click="addMedicalRecordBoList(5)"
                    >添加一行
                    </el-button
                    >
                  </div>
                </div>

                <el-table
                  class="chushiyaowuzhenliao"
                  :data="form.initTraditionalMedicalList"
                  key="initTraditionalMedicalList "
                  :cell-class-name="isRender"
                  ref="multipleTable5"
                  border
                >
                  <el-table-column
                    prop="pillsName"
                    label="药物名称"
                    fixed
                    min-width="400"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <el-autocomplete
                        style="width: 100%"
                        type="textarea"
                        autosize
                        class="require_des"
                        v-model="scope.row.pillsName"
                        :fetch-suggestions="querySearchAsync"
                        @select="handleSelect"
                      >
                        <template slot-scope="{ item }">
                          <el-tooltip
                            class="item"
                            effect="dark"
                            :content="item.value"
                            placement="right-end"
                          >
                            <div
                              class="query-item-text"
                              style="
                                overflow: hidden;
                                text-overflow: ellipsis;
                                white-space: nowrap;
                              "
                            >
                              {{ item.value }}
                            </div>
                          </el-tooltip>
                        </template>
                      </el-autocomplete
                      >
                    </template>
                  </el-table-column>
                  <el-table-column
                    align="center"
                    prop="pillsUsage"
                    label="用法用量"
                    min-width="100"
                  >
                    <template slot-scope="scope">
                      <el-input
                        type="textarea"
                        class="require_des"
                        v-model="scope.row.pillsUsage"
                      ></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="beginDate"
                    label="起始日期"
                    align="center"
                    width="190"
                  >
                    <template slot-scope="scope">
                      <el-date-picker
                        v-model="scope.row.beginDate"
                        type="datetime"
                        clearable
                        format="yyyy-MM-dd"
                        value-format="yyyy-MM-dd HH:mm"
                        placeholder="请选择起始日期"
                        :picker-options="pickerOptions"
                        :disabledDate="disabledDate"
                      >
                      </el-date-picker>
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="address"
                    label="操作"
                    width="130"
                    fixed="right"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <el-button
                        v-if="scope.$index > 0"
                        type="text"
                        size="small"
                        @click="moveUp(scope.row, scope.$index, 4)"
                      >
                        上移
                      </el-button>
                      <el-button
                        v-if="
                          scope.$index <
                          form.initTraditionalMedicalList.length - 1
                        "
                        type="text"
                        size="small"
                        @click="moveDown(scope.row, scope.$index, 4)"
                      >
                        下移
                      </el-button>
                      <el-button
                        type="text"
                        size="small"
                        @click="
                          delMedicalRecordBoList(scope.row, scope.$index, 5)
                        "
                      >删除
                      </el-button
                      >
                    </template>
                  </el-table-column>
                </el-table>
                <el-table
                  v-if="false"
                  :border="true"
                  :data="form.initalMedicalRecordVoList"
                  key="initalMedicalRecordVoList"
                  style="width: 100%"
                >
                  <el-table-column
                    prop="purpose"
                    label="用药目的"
                    width="80"
                    fixed
                    align="center"
                  >
                    <template slot-scope="scope">
                      <el-input
                        class="require_des"
                        v-model="scope.row.purpose"
                      ></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="pillsName"
                    label="药物名称"
                    width="250"
                    fixed
                    align="center"
                  >
                    <template slot-scope="scope">
                      <el-autocomplete
                        class="require_des"
                        v-model="scope.row.pillsName"
                        :fetch-suggestions="querySearchAsync"
                        @select="handleSelect"
                      >
                        <template slot-scope="{ item }">
                          <el-tooltip
                            class="item"
                            effect="dark"
                            :content="item.value"
                            placement="right-end"
                          >
                            <div
                              class="query-item-text"
                              style="
                                width: 170px;
                                overflow: hidden;
                                text-overflow: ellipsis;
                                white-space: nowrap;
                              "
                            >
                              {{ item.value }}
                            </div>
                          </el-tooltip>
                        </template>
                      </el-autocomplete
                      >
                    </template>
                  </el-table-column>
                  <el-table-column
                    align="center"
                    prop="amountPer"
                    label="单次剂量"
                    width="100"
                    fixed
                  >
                    <template slot-scope="scope">
                      <el-input
                        class="require_des"
                        v-model="scope.row.amountPer"
                      ></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    align="center"
                    prop="pillsUsage"
                    label="用法"
                    width="100"
                  >
                    <template slot-scope="scope">
                      <el-input
                        class="require_des"
                        v-model="scope.row.pillsUsage"
                      ></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    align="center"
                    prop="frequency"
                    label="频次"
                    width="100"
                  >
                    <template slot-scope="scope">
                      <el-input
                        class="require_des"
                        v-model="scope.row.frequency"
                      ></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="beginDate"
                    label="起始日期"
                    align="center"
                    width="130"
                  >
                    <template slot-scope="scope">
                      <el-date-picker
                        v-model="scope.row.beginDate"
                        type="datetime"
                        clearable
                        format="yyyy-MM-dd HH:mm"
                        value-format="yyyy-MM-dd HH:mm"
                        placeholder="请选择起始日期"
                        :picker-options="pickerOptions"
                        :disabledDate="disabledDate"
                      >
                      </el-date-picker>
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="address"
                    label="操作"
                    width="47"
                    align="center"
                    fixed="right"
                  >
                    <template slot-scope="scope">
                      <el-button
                        type="text"
                        size="small"
                        @click="
                          delMedicalRecordBoList(scope.row, scope.$index, 2)
                        "
                      >删除
                      </el-button
                      >
                    </template>
                  </el-table-column>
                </el-table>
              </el-form-item>

              <el-form-item label="药学评估结果：">
                <div style="color: #aaaaaa">患者一般情况评估结果：</div>
                <div class="input" v-if="queryParams.selfCareAbilityLabel">
                  <div>自理能力：{{ queryParams.selfCareAbilityLabel }}</div>
                  <div>
                    患者自述能力：{{ queryParams.expressionAbilityLabel }}
                  </div>
                  <div>护理级别：{{ queryParams.careLevelLabel }}</div>
                  <div>合计：{{ queryParams.generalConditionScore }}</div>
                </div>
                <div style="color: #aaaaaa">患者生活方式评估结果：</div>
                <div class="input" v-if="queryParams.smokeWineLabel">
                  <div>烟酒嗜好：{{ queryParams.smokeWineLabel }}</div>
                  <div>饮食嗜好：{{ queryParams.eatLabel }}</div>
                  <div>运动习惯：{{ queryParams.sportLabel }}</div>
                  <div>合计：{{ queryParams.liveStyleScore }}</div>
                </div>
                <div style="color: #aaaaaa">既往用药依从性评估果：</div>
                <div class="input" v-if="queryParams.isForgetTakePillsLabel">
                  <div>
                    <span>{{
                        queryParams.isForgetTakePillsSocre == 0 ? '是：' : '否：'
                      }}</span>
                    {{ queryParams.isForgetTakePillsLabel }}
                  </div>
                  <div>
                    <span>{{
                        queryParams.isReduceStopPillsScore == 0 ? '是：' : '否：'
                      }}</span>
                    {{ queryParams.isReduceStopPillsLabel }}
                  </div>
                  <div>
                    <span>{{
                        queryParams.isForgetCarryPillsScore == 0 ? '是：' : '否：'
                      }}</span>
                    {{ queryParams.isForgetCarryPillsLabel }}
                  </div>
                  <div>
                    <span>{{
                        queryParams.isInsistScore == 0 ? '是：' : '否：'
                      }}</span>
                    {{ queryParams.isInsistLabel }}
                  </div>
                  <div>
                    <span>{{
                        queryParams.isTimeAmountScore == 0 ? '是：' : '否：'
                      }}</span>
                    {{ queryParams.isTimeAmountLabel }}
                  </div>
                  <div>合计：{{ queryParams.eatPillsHobbyScore }}</div>
                </div>
                <div style="color: #aaaaaa">一般医药知识评估结果：</div>
                <div class="input" v-if="queryParams.illnessKnowLabel">
                  <div>
                    对所患疾病了解程度：{{ queryParams.illnessKnowLabel }}
                  </div>
                  <div>药物用法用量：{{ queryParams.pillsAmountLabel }}</div>
                  <div>潜在不良反应：{{ queryParams.pillsBadLabel }}</div>
                  <div>药物相互作用：{{ queryParams.pillsEffectLabel }}</div>
                  <div>合计：{{ queryParams.generalPillsScore }}</div>
                </div>
                <div style="color: #aaaaaa">药学评估结论：</div>
                <div class="input" v-if="queryParams.totalScore">
                  <div>
                    {{
                      queryParams.totalScore > 80
                        ? '良好'
                        : queryParams.totalScore >= 60
                        ? '合格'
                        : '不合格'
                    }}
                  </div>
                  <div>总分：{{ queryParams.totalScore }}</div>
                </div>
              </el-form-item>
              <el-form-item
                label="药学监护计划："
                prop="medicalGuardianSchedule"
              >
                <el-button
                  style="background-color: #b8dfea; margin-bottom: 10px"
                  @click="templateInfo"
                >引用模板
                </el-button
                >
                <el-input
                  type="textarea"
                  :rows="8"
                  placeholder="（1）病情变化（注：从患者疾病的临床表现（症状、体征）的变化包括中医望闻问切诊内容，辅助检查结果，等指标情况确定有效性和安全性的监护时间和方法等。用药期间有无新发症状是否与药物存在相关性等安全性。）
                                （2）合理用药情况（注：主要记录患者住院医嘱前置审核中需要医师双签的内容及个体化给药相关检测结果（如血药浓度监测和基因检测）并做简要分析评价。）
                               （3）医保费用情况（注:统计患者药物治疗方案中各类药物的费用占比情况，包括药品使用金额占比和自费药品使用金额占比。）
                              （4）其他药事管理指标（注：重点汇总分析每位患者治疗过程中的药物治疗方案是否满足医疗机构各项药事管理指标的要求）"
                  v-model="form.medicalGuardianSchedule"
                />
              </el-form-item>
            </el-form>
            <div class="r" style="justify-content: space-between">
              <span></span>
              <div>
                <el-button
                  v-hasPermi="['workstation:medicationRecord:download']"
                  :loading="downMedicationRecordLoading"
                  type="primary"
                  @click="downMedicationRecord"
                >下 载
                </el-button
                >
                <el-button
                  v-hasPermi="['workstation:medicationRecord:add']"
                  :loading="MedicationRecordLoading"
                  type="primary"
                  @click="submitMedicationRecord"
                  style="background-color: #1292b9"
                >保 存
                </el-button
                >
              </div>
            </div>
          </div>
        </el-collapse-item>
        <el-collapse-item title="用药时间轴" name="3">
          <YongYaoShiJianZhou
            :medicalRecordNo="medicalRecordNo"
            ref="yongyaoshijianzhou"
            :ruyuanTime="form.patientBaseInfoVo.admissionTime"
            :chuyuanTime="form.patientBaseInfoVo.dischargeTime"
          />
        </el-collapse-item>
        <el-collapse-item title="药学监护记录" name="4">
          <div
            style="
              padding: 15px 30px;
              border: 1px solid rgba(242, 242, 242, 1);
              box-sizing: border-box;
            "
          >
            <div
              v-for="(
                item, index
              ) in pharmaceuticalCare.pharmaceuticalCareDetailVoList"
              :key="index"
            >
              <div
                style="
                  display: flex;
                  align-items: center;
                  justify-content: space-between;
                "
              >
                <div class="r">
                  <div class="r">
                    <span style="font-size: 16px">时间：</span>
                    <el-date-picker
                      v-model="item.careDate"
                      type="date"
                      value-format="yyyy-MM-dd"
                      format="yyyy-MM-dd"
                      placeholder="选择日期"
                      :picker-options="pickerOptions"
                      :disabledDate="disabledDate"
                      @change="getDateHandle(item, index)"
                    >
                    </el-date-picker>
                  </div>
                  <div class="r ml15">
                    <span
                      style="
                        display: inline-block;
                        width: 83px;
                        font-size: 16px;
                      "
                    >入院天数：</span
                    >
                    <el-input disabled style="width:100px" v-model="item.inHospitalDays"></el-input>
                  </div>
                </div>
                <div class="r">
                  <span style="font-size: 16px;">药学监护级别：</span>
                  <el-select
                    v-model="item.guardianLevel"
                    placeholder="请选择"
                    clearable
                    style="width:100px;margin-right:10px"
                  >
                    <el-option
                      v-for="(ele, index) in guardianLevel"
                      :key="index"
                      :label="ele.dictLabel"
                      :value="ele.dictValue"
                    ></el-option>
                  </el-select>
                  <el-button
                    style="background-color: #f4b3bb"
                    @click="delRecordOne(item, index)"
                  >删除
                  </el-button
                  >
                  <el-button
                    type="primary"
                    style="background-color: #1292b9; color: #fff; height: 36px"
                    @click="saveYaoXueJiLv(1)"
                  >保 存
                  </el-button
                  >
                </div>
              </div>
              <div class="mt10">
                <div style="font-size: 16px">生命体征：</div>
                <el-input
                  :disabled="item.createBy == 'HIS' ? true : false"
                  type="textarea"
                  :rows="4"
                  placeholder="体温、心率、呼吸、血压为必填项"
                  v-model="item.vitalSigns"
                />
              </div>
              <div class="mt10">
                <div style="font-size: 16px">监护计划执行情况：</div>
                <el-input
                  type="textarea"
                  :rows="6"
                  placeholder="根据制定的监护计划，记录患者的病情变化、合理用药情况、医保费用和其他药事管理指标变化情况等"
                  v-model="item.executiveCondition"
                />
              </div>
              <div class="mt10">
                <div class="r" style="justify-content: space-between">
                  <div style="font-size: 16px">
                    <span>药物治疗方案调整：</span>
                    <span style="font-size: 13px; margin-right: 5px"
                    >长嘱临嘱</span
                    >
                    <el-radio-group v-model="item.medicationSummaryOption1">
                      <el-radio :label="true">有</el-radio>
                      <el-radio :label="false">无</el-radio>
                    </el-radio-group>
                  </div>
                  <div v-if="item.medicationSummaryOption1 == true">
                    <el-button
                      style="margin-bottom: 10px"
                      type="primary"
                      @click="getHISdirLog(7, index)"
                    >查询HIS医嘱用药
                    </el-button
                    >
                    <el-button
                      style="background-color: #b8dfea; margin-bottom: 10px"
                      @click="addMedicalRecordBoList(8, index)"
                    >添加一行
                    </el-button
                    >
                  </div>
                </div>
                <el-table
                  v-if="item.medicationSummaryOption1 == true"
                  class="chushiyaowuzhenliao"
                  :data="item.careDetailMedicalList"
                  key="careDetailMedicalList"
                  ref="multipleTable10"
                  border
                >
                  <el-table-column
                    prop="purpose"
                    label="用药调整"
                    width="100"
                    fixed
                    align="center"
                  >
                    <template slot-scope="scope">
                      <el-select
                        v-model="scope.row.purpose"
                        placeholder="请选择"
                        :style="{ width: '100%' }"
                      >
                        <el-option label="新增" value="新增"></el-option>
                        <el-option label="停止" value="停止"></el-option>
                        <el-option label="调整" value="调整"></el-option>
                      </el-select>
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="pillsName"
                    label="药物名称"
                    min-width="250"
                    fixed
                    align="center"
                    style="display: flex; align-items: center"
                  >
                    <template slot-scope="scope">
                      <el-autocomplete
                        style="width: 100%"
                        class="require_des"
                        v-model="scope.row.pillsName"
                        :fetch-suggestions="querySearchAsync"
                        @select="handleSelect"
                      >
                        <template slot-scope="{ item }">
                          <el-tooltip
                            class="item"
                            effect="dark"
                            :content="item.value"
                            placement="right-end"
                          >
                            <div
                              class="query-item-text"
                              style="
                                overflow: hidden;
                                text-overflow: ellipsis;
                                white-space: nowrap;
                              "
                            >
                              {{ item.value }}
                            </div>
                          </el-tooltip>
                        </template>
                      </el-autocomplete>
                    </template>
                  </el-table-column>
                  <el-table-column
                    align="center"
                    prop="amountPer"
                    label="单次剂量"
                    min-width="120"
                    fixed
                  >
                    <template slot-scope="scope">
                      <el-input
                        class="require_des"
                        v-model="scope.row.amountPer"
                      ></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    align="center"
                    prop="pillsUsage"
                    label="用法"
                    min-width="130"
                  >
                    <template slot-scope="scope">
                      <el-input
                        class="require_des"
                        v-model="scope.row.pillsUsage"
                      ></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    align="center"
                    prop="frequency"
                    label="频次"
                    min-width="130"
                  >
                    <template slot-scope="scope">
                      <el-input
                        class="require_des"
                        v-model="scope.row.frequency"
                      ></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="beginDate"
                    label="起始日期"
                    align="center"
                    width="190"
                  >
                    <template slot-scope="scope">
                      <el-date-picker
                        v-model="scope.row.beginDate"
                        type="datetime"
                        clearable
                        format="yyyy-MM-dd"
                        value-format="yyyy-MM-dd HH:mm"
                        placeholder="请选择起始日期"
                        :picker-options="pickerOptions"
                        :disabledDate="disabledDate"
                      >
                      </el-date-picker>
                    </template>
                  </el-table-column>
                  <el-table-column
                    align="center"
                    prop="pillsCycle"
                    label="备注"
                    min-width="130"
                  >
                    <template slot-scope="scope">
                      <el-input
                        class="require_des"
                        v-model="scope.row.pillsCycle"
                      ></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="address"
                    label="操作"
                    width="130"
                    fixed="right"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <el-button
                        v-if="scope.$index > 0"
                        type="text"
                        size="small"
                        @click="moveUp(scope.row, scope.$index, 5, index)"
                      >
                        上移
                      </el-button>
                      <el-button
                        v-if="
                          scope.$index < item.careDetailMedicalList.length - 1
                        "
                        type="text"
                        size="small"
                        @click="moveDown(scope.row, scope.$index, 5, index)"
                      >
                        下移
                      </el-button>
                      <el-button
                        type="text"
                        size="small"
                        @click="
                          delMedicalRecordBoList(
                            scope.row,
                            scope.$index,
                            8,
                            index
                          )
                        "
                      >删除
                      </el-button
                      >
                    </template>
                  </el-table-column>
                </el-table>

                <div
                  class="r mt20"
                  style="justify-content: space-between; padding-left: 143px"
                >
                  <span>
                    中药饮片
                    <el-radio-group v-model="item.medicationSummaryOption2">
                      <el-radio :label="true">有</el-radio>
                      <el-radio :label="false">无</el-radio>
                    </el-radio-group>
                  </span>
                  <div v-if="item.medicationSummaryOption2 == true">
                    <el-button
                      style="margin-bottom: 10px"
                      type="primary"
                      @click="getHISdirLog(8, index)"
                    >查询HIS中药饮片
                    </el-button
                    >
                    <el-button
                      style="
                        background-color: #b8dfea;
                        margin-bottom: 10px;
                        float: right;
                      "
                      @click="addMedicalRecordBoList(9, index)"
                    >添加一行
                    </el-button
                    >
                  </div>
                </div>

                <el-table
                  v-if="item.medicationSummaryOption2 == true"
                  class="chushiyaowuzhenliao"
                  :data="item.traditionalMedicalList"
                  key="traditionalMedicalList"
                  ref="multipleTable11"
                  border
                >
                  <el-table-column
                    prop="purpose"
                    label="用药调整"
                    width="100"
                    fixed
                    align="center"
                  >
                    <template slot-scope="scope">
                      <el-select
                        v-model="scope.row.purpose"
                        placeholder="请选择"
                        :style="{ width: '100%' }"
                      >
                        <el-option label="新增" value="新增"></el-option>
                        <el-option label="停止" value="停止"></el-option>
                        <el-option label="调整" value="调整"></el-option>
                      </el-select>
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="pillsName"
                    label="药物名称"
                    fixed
                    min-width="400"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <el-autocomplete
                        style="width: 100%"
                        type="textarea"
                        :autosize="{ minRows: 1 }"
                        class="require_des"
                        v-model="scope.row.pillsName"
                        :fetch-suggestions="querySearchAsync"
                        @select="handleSelect"
                      >
                        <template slot-scope="{ item }">
                          <el-tooltip
                            class="item"
                            effect="dark"
                            :content="item.value"
                            placement="right-end"
                          >
                            <div
                              class="query-item-text"
                              style="
                                overflow: hidden;
                                text-overflow: ellipsis;
                                white-space: nowrap;
                              "
                            >
                              {{ item.value }}
                            </div>
                          </el-tooltip>
                        </template>
                      </el-autocomplete
                      >
                    </template>
                  </el-table-column>
                  <el-table-column
                    align="center"
                    prop="pillsUsage"
                    label="用法用量"
                    min-width="130"
                  >
                    <template slot-scope="scope">
                      <el-input
                        type="textarea"
                        class="require_des"
                        v-model="scope.row.pillsUsage"
                      ></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="beginDate"
                    label="起始日期"
                    align="center"
                    width="190"
                  >
                    <template slot-scope="scope">
                      <el-date-picker
                        v-model="scope.row.beginDate"
                        type="datetime"
                        clearable
                        format="yyyy-MM-dd"
                        value-format="yyyy-MM-dd HH:mm"
                        placeholder="请选择起始日期"
                        :picker-options="pickerOptions"
                        :disabledDate="disabledDate"
                      >
                      </el-date-picker>
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="address"
                    label="操作"
                    width="130"
                    fixed="right"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <el-button
                        v-if="scope.$index > 0"
                        type="text"
                        size="small"
                        @click="moveUp(scope.row, scope.$index, 6, index)"
                      >
                        上移
                      </el-button>
                      <el-button
                        v-if="
                          scope.$index < item.traditionalMedicalList.length - 1
                        "
                        type="text"
                        size="small"
                        @click="moveDown(scope.row, scope.$index, 6, index)"
                      >
                        下移
                      </el-button>
                      <el-button
                        type="text"
                        size="small"
                        @click="
                          delMedicalRecordBoList(
                            scope.row,
                            scope.$index,
                            9,
                            index
                          )
                        "
                      >删除
                      </el-button
                      >
                    </template>
                  </el-table-column>
                </el-table>
              </div>
              <div class="mt10">
                <div style="font-size: 16px">
                  <span>药学监护计划调整：</span>
                  <el-radio-group v-model="item.carePlanAdjustmentOption">
                    <el-radio :label="'true'">有</el-radio>
                    <el-radio :label="'false'">无</el-radio>
                  </el-radio-group>
                </div>
                <el-input
                  type="textarea"
                  :rows="4"
                  placeholder="治疗方案调整时针对增加的药物"
                  v-model="item.carePlanAdjustment"
                />
              </div>
              <div class="mt10">
                <div style="font-size: 16px">
                  <span>用药教育：</span
                  ><span>
                    <el-radio-group v-model="item.pillsEducationOption">
                      <el-radio :label="'true'">有</el-radio>
                      <el-radio :label="'false'">无</el-radio>
                    </el-radio-group>
                  </span>
                </div>
                <el-input
                  type="textarea"
                  :rows="4"
                  placeholder=""
                  v-model="item.pillsEducation"
                />
              </div>
              <div class="mt10">
                <div style="font-size: 16px">
                  <span>用药建议：</span
                  ><span>
                    <el-radio-group v-model="item.medicationSummaryOption3">
                      <el-radio :label="'true'">有</el-radio>
                      <el-radio :label="'false'">无</el-radio>
                    </el-radio-group>
                  </span>
                </div>
                <el-input
                  type="textarea"
                  :rows="4"
                  placeholder=""
                  v-model="item.pillsSuggest"
                />
              </div>
              <el-divider
                v-if="
                  index !==
                  pharmaceuticalCare.pharmaceuticalCareDetailVoList.length - 1
                "
              ></el-divider>
            </div>

            <div class="r mt20 mb10" style="justify-content: space-between">
              <div>
                <el-button
                  style="background-color: #b8dfea"
                  @click="addRecord(1)"
                >添加记录
                </el-button
                >
              </div>
              <div>
                <el-button
                  v-hasPermi="['workstation:pharmaceuticalCare:export']"
                  :loading="downpharmaceuticalCareLoading"
                  type="primary"
                  @click="downpharmaceuticalCare"
                >下 载
                </el-button
                >
                <el-button
                  type="primary"
                  style="background-color: #1292b9; color: #fff; height: 36px"
                  @click="saveYaoXueJiLv(1)"
                >保 存
                </el-button
                >
              </div>
            </div>
            <el-divider></el-divider>
            <div>
              <div class="r" style="justify-content: space-between">
                <div class="r" style="font-size: 16px; margin-bottom: 10px">
                  <span>出院用药：</span>
                  <el-radio-group v-model="pharmaceuticalCare.dischargePillsOption">
                    <el-radio :label="'true'">有</el-radio>
                    <el-radio :label="'false'">无</el-radio>
                  </el-radio-group>
                </div>
                <div v-if="pharmaceuticalCare.dischargePillsOption == 'true'">
                  <el-button
                    style="margin-bottom: 10px"
                    type="primary"
                    @click="getHISdirLog(9)"
                  >查询HIS医嘱用药
                  </el-button
                  >
                  <el-button
                    style="
                      background-color: #b8dfea;
                      margin-bottom: 10px;
                      float: right;
                    "
                    @click="addMedicalRecordBoList(7)"
                  >添加一行
                  </el-button
                  >
                </div>
              </div>
              <el-table
                v-if="pharmaceuticalCare.dischargePillsOption == 'true'"
                class="chushiyaowuzhenliao"
                :data="pharmaceuticalCare.educWestMedicalRecordList"
                key="educWestMedicalRecordList"
                ref="multipleTable46"
                border
              >
                <el-table-column
                  prop="pillsName"
                  label="药物名称"
                  min-width="250"
                  fixed
                  align="center"
                  style="display: flex; align-items: center"
                >
                  <template slot-scope="scope">
                    <el-autocomplete
                      style="width: 100%"
                      class="require_des"
                      v-model="scope.row.pillsName"
                      :fetch-suggestions="querySearchAsync"
                      @select="handleSelect"
                    >
                      <template slot-scope="{ item }">
                        <el-tooltip
                          class="item"
                          effect="dark"
                          :content="item.value"
                          placement="right-end"
                        >
                          <div
                            class="query-item-text"
                            style="
                              overflow: hidden;
                              text-overflow: ellipsis;
                              white-space: nowrap;
                            "
                          >
                            {{ item.value }}
                          </div>
                        </el-tooltip>
                      </template>
                    </el-autocomplete
                    >
                  </template>
                </el-table-column>
                <el-table-column
                  align="center"
                  prop="amountPer"
                  label="单次剂量"
                  min-width="120"
                  fixed
                >
                  <template slot-scope="scope">
                    <el-input
                      class="require_des"
                      v-model="scope.row.amountPer"
                    ></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  align="center"
                  prop="pillsUsage"
                  label="用法"
                  min-width="130"
                >
                  <template slot-scope="scope">
                    <el-input
                      class="require_des"
                      v-model="scope.row.pillsUsage"
                    ></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  align="center"
                  prop="frequency"
                  label="频次"
                  min-width="130"
                >
                  <template slot-scope="scope">
                    <el-input
                      class="require_des"
                      v-model="scope.row.frequency"
                    ></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="pillsCycle"
                  label="用药周期"
                  align="center"
                  width="190"
                >
                  <template slot-scope="scope">
                    <el-input
                      class="require_des"
                      v-model="scope.row.pillsCycle"
                    ></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  label="操作"
                  width="130"
                  align="center"
                  fixed="right"
                >
                  <template slot-scope="scope">
                    <el-button
                      v-if="scope.$index > 0"
                      type="text"
                      size="small"
                      @click="moveUp(scope.row, scope.$index, 7)"
                    >
                      上移
                    </el-button>
                    <el-button
                      v-if="
                        scope.$index <
                        pharmaceuticalCare.educWestMedicalRecordList.length - 1
                      "
                      type="text"
                      size="small"
                      @click="moveDown(scope.row, scope.$index, 7)"
                    >
                      下移
                    </el-button>
                    <el-button
                      type="text"
                      size="small"
                      @click="
                        delMedicalRecordBoList(scope.row, scope.$index, 7)
                      "
                    >删除
                    </el-button
                    >
                  </template>
                </el-table-column>
              </el-table>
              <div class="r mt10" style="justify-content: space-between;padding-left:80px">
                <span></span>
                <div v-if="pharmaceuticalCare.dischargePillsOption == 'true'">
                  <el-button
                    style="margin-bottom: 10px"
                    type="primary"
                    @click="getHISdirLog(10)"
                  >查询HIS中药饮片
                  </el-button
                  >
                  <el-button
                    style="
                      background-color: #b8dfea;
                      margin-bottom: 10px;
                      float: right;
                    "
                    @click="addMedicalRecordBoList(10)"
                  >添加一行
                  </el-button
                  >
                </div>
              </div>

              <el-table
                v-if="pharmaceuticalCare.dischargePillsOption == 'true'"
                class="chushiyaowuzhenliao"
                :data="pharmaceuticalCare.educTraditionalMedicalRecordList"
                key="educTraditionalMedicalRecordList"
                ref="multipleTable23"
                border
              >
                <el-table-column
                  prop="pillsName"
                  label="药物名称"
                  fixed
                  min-width="400"
                  align="center"
                >
                  <template slot-scope="scope">
                    <el-autocomplete
                      style="width: 100%"
                      type="textarea"
                      autosize
                      class="require_des"
                      v-model="scope.row.pillsName"
                      :fetch-suggestions="querySearchAsync"
                      @select="handleSelect"
                    >
                      <template slot-scope="{ item }">
                        <el-tooltip
                          class="item"
                          effect="dark"
                          :content="item.value"
                          placement="right-end"
                        >
                          <div
                            class="query-item-text"
                            style="
                              overflow: hidden;
                              text-overflow: ellipsis;
                              white-space: nowrap;
                            "
                          >
                            {{ item.value }}
                          </div>
                        </el-tooltip>
                      </template>
                    </el-autocomplete
                    >
                  </template>
                </el-table-column>
                <el-table-column
                  align="center"
                  prop="pillsUsage"
                  label="用法用量"
                  min-width="130"
                >
                  <template slot-scope="scope">
                    <el-input
                      type="textarea"
                      class="require_des"
                      v-model="scope.row.pillsUsage"
                    ></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="pillsCycle"
                  label="用药周期"
                  align="center"
                  width="190"
                >
                  <template slot-scope="scope">
                    <el-input
                      class="require_des"
                      v-model="scope.row.pillsCycle"
                    ></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="beginDate"
                  label="结束日期"
                  align="center"
                  width="190"
                >
                  <template slot-scope="scope">
                    <el-date-picker
                      v-model="scope.row.endDate"
                      type="datetime"
                      clearable
                      format="yyyy-MM-dd"
                      value-format="yyyy-MM-dd HH:mm"
                      placeholder="请选择结束日期"
                      :picker-options="pickerOptions"
                      :disabledDate="disabledDate"
                    >
                    </el-date-picker>
                  </template>
                </el-table-column>
                <el-table-column
                  label="操作"
                  width="130"
                  align="center"
                  fixed="right"
                >
                  <template slot-scope="scope">
                    <el-button
                      v-if="scope.$index > 0"
                      type="text"
                      size="small"
                      @click="moveUp(scope.row, scope.$index, 8)"
                    >
                      上移
                    </el-button>
                    <el-button
                      v-if="
                        scope.$index <
                        pharmaceuticalCare.educTraditionalMedicalRecordList
                          .length -
                          1
                      "
                      type="text"
                      size="small"
                      @click="moveDown(scope.row, scope.$index, 8)"
                    >
                      下移
                    </el-button>
                    <el-button
                      type="text"
                      size="small"
                      @click="
                        delMedicalRecordBoList(scope.row, scope.$index, 10)
                      "
                    >删除
                    </el-button
                    >
                  </template>
                </el-table-column>
              </el-table>
            </div>

            <!-- 出院用药教育： -->
            <div class="mt20">
              <div style="font-size: 16px">出院用药教育：</div>
              <el-button
                style="background-color: #b8dfea; margin: 10px 0px"
                @click="useEducation"
              >引用模板
              </el-button
              >
              <el-input
                type="textarea"
                :rows="8"
                placeholder="请输入内容"
                v-model="pharmaceuticalCare.dischargePharmacyEducation"
              />
            </div>
            <!-- 出院用药教育： -->
            <div class="r mt10" style="justify-content: space-between">
              <span></span>
              <div>
                <el-button
                  v-hasPermi="['workstation:pharmaceuticalCare:download']"
                  :loading="downpharmaceuticalCareDetailVoListLoading"
                  type="primary"
                  @click="downpharmaceuticalCareDetailVoList"
                >下 载
                </el-button
                >
                <el-button
                  v-hasPermi="['workstation:pharmaceuticalCare:add']"
                  style="background-color: #1292b9; color: #fff; height: 36px"
                  @click="saveYaoXueJiLv"
                >保存
                </el-button
                >
              </div>
            </div>
          </div>
        </el-collapse-item>
        <el-collapse-item title="药历小结" name="5" style="margin-bottom: 0px">
          <div
            style="padding: 15px 15px; border: 1px solid rgba(242, 242, 242, 1)"
          >
            <el-form
              ref="form"
              :model="yaoLiXiaoJieList"
              :rules="rules"
              label-width="100px"
              label-position="left"
            >
              <div class="label1">
                <el-row>
                  <el-col :span="12">
                    <el-form-item label="入院日期：" prop="admissionTime">
                      <el-date-picker
                        clearable
                        disabled
                        v-model="form.patientBaseInfoVo.admissionTime"
                        type="date"
                        format="yyyy-MM-dd"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择入院日期"
                        :picker-options="pickerOptions"
                        :disabledDate="disabledDate"
                      >
                      </el-date-picker>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="出院时间：" prop="outHospitalDate">
                      <el-date-picker
                        clearable
                        disabled
                        v-model="form.patientBaseInfoVo.dischargeTime"
                        type="date"
                        format="yyyy-MM-dd"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择出院时间"
                        :picker-options="pickerOptions"
                        :disabledDate="disabledDate"
                      >
                      </el-date-picker>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24">
                    <el-form-item label="住院天数：" prop="inHospitalDays">
                      <el-input
                        disabled
                        v-model="yaoLiXiaoJieList.inHospitalDays"
                        placeholder="请输入住院天数"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-form-item
                  label="西医诊断："
                  prop="admittingDiagnosisWestern"
                >
                  <el-input
                    v-model="yaoLiXiaoJieList.admittingDiagnosisWestern"
                    type="textarea"
                    :rows="4"
                    placeholder="请输入内容"
                  />
                </el-form-item>
                <el-form-item
                  label="中医诊断："
                  prop="traditionalDiagnosisVoList"
                >
                  <el-button
                    style="background-color: #b8dfea; margin-bottom: 10px"
                    @click="addTraditionalDiagnosisVoList(1)"
                  >添加一行
                  </el-button
                  >
                  <el-table
                    :border="true"
                    :data="yaoLiXiaoJieList.traditionalDiagnosisVoList"
                    key="traditionalDiagnosisVoList"
                    style="width: 100%"
                  >
                    <el-table-column
                      prop="illnessName"
                      label="病"
                      width=""
                      align="center"
                    >
                      <template slot-scope="scope">
                        <el-input
                          class="require_des"
                          v-model="scope.row.illnessName"
                        ></el-input>
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="patternOfSyndrome"
                      label="证型"
                      align="center"
                    >
                      <template slot-scope="scope">
                        <el-input
                          class="require_des"
                          v-model="scope.row.patternOfSyndrome"
                        ></el-input>
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="address"
                      label="操作"
                      width="60"
                      align="center"
                    >
                      <template slot-scope="scope">
                        <el-button
                          type="text"
                          size="small"
                          @click="
                            delTraditionalDiagnosisVoList(
                              scope.row,
                              scope.$index,
                              1
                            )
                          "
                        >删除
                        </el-button
                        >
                      </template>
                    </el-table-column>
                  </el-table>
                </el-form-item>
                <el-form-item
                  label="住院期间治疗药物汇总："
                  prop="medicalRecordBoList"
                >
                  <div style="float: right">
                    <el-button
                      style="margin-bottom: 10px"
                      type="primary"
                      @click="getHISdirLog(3)"
                    >查询HIS医嘱用药
                    </el-button
                    >
                    <el-button
                      style="background-color: #b8dfea; margin-bottom: 10px"
                      @click="addMedicalRecordBoList(3)"
                    >添加一行
                    </el-button
                    >
                  </div>
                  <el-table
                    class="chushiyaowuzhenliao"
                    :data="yaoLiXiaoJieList.medicalRecordVoList"
                    key="medicalRecordVoList"
                    style="width: 100%"
                    :cell-class-name="isRender"
                    ref="multipleTable2"
                    border
                  >
                    <el-table-column
                      prop="pillsName"
                      label="药物名称"
                      min-width="250"
                      fixed
                      align="center"
                    >
                      <template slot-scope="scope">
                        <el-autocomplete
                          style="width: 100%"
                          type="textarea"
                          autosize
                          class="require_des"
                          v-model="scope.row.pillsName"
                          :fetch-suggestions="querySearchAsync"
                          @select="handleSelect"
                        >
                          <template slot-scope="{ item }">
                            <el-tooltip
                              class="item"
                              effect="dark"
                              :content="item.value"
                              placement="right-end"
                            >
                              <div
                                class="query-item-text"
                                style="
                                  overflow: hidden;
                                  text-overflow: ellipsis;
                                  white-space: nowrap;
                                "
                              >
                                {{ item.value }}
                              </div>
                            </el-tooltip>
                          </template>
                        </el-autocomplete
                        >
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="amountPer"
                      label="单次剂量"
                      min-width="100"
                      fixed
                    >
                      <template slot-scope="scope">
                        <el-input
                          class="require_des"
                          v-model="scope.row.amountPer"
                        ></el-input>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="pillsUsage"
                      label="用法"
                      min-width="100"
                    >
                      <template slot-scope="scope">
                        <el-input
                          class="require_des"
                          v-model="scope.row.pillsUsage"
                        ></el-input>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="frequency"
                      label="频次"
                      min-width="100"
                    >
                      <template slot-scope="scope">
                        <el-input
                          class="require_des"
                          v-model="scope.row.frequency"
                        ></el-input>
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="beginDate"
                      label="开始日期"
                      align="center"
                      width="180"
                    >
                      <template slot-scope="scope">
                        <el-date-picker
                          v-model="scope.row.beginDate"
                          type="datetime"
                          clearable
                          format="yyyy-MM-dd"
                          value-format="yyyy-MM-dd HH:mm"
                          placeholder="请选择开始日期"
                          :picker-options="pickerOptions"
                          :disabledDate="disabledDate"
                        >
                        </el-date-picker>
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="endDate"
                      label="结束日期"
                      align="center"
                      width="180"
                    >
                      <template slot-scope="scope">
                        <el-date-picker
                          v-model="scope.row.endDate"
                          type="datetime"
                          clearable
                          format="yyyy-MM-dd"
                          value-format="yyyy-MM-dd HH:mm"
                          :picker-options="pickerOptions"
                          :disabledDate="disabledDate"
                          placeholder="请选择结束日期"
                        >
                        </el-date-picker>
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="address"
                      label="操作"
                      width="130"
                      fixed="right"
                      align="center"
                    >
                      <template slot-scope="scope">
                        <el-button
                          v-if="scope.$index > 0"
                          type="text"
                          size="small"
                          @click="moveUp(scope.row, scope.$index, 9)"
                        >
                          上移
                        </el-button>
                        <el-button
                          v-if="
                            scope.$index <
                            yaoLiXiaoJieList.medicalRecordVoList.length - 1
                          "
                          type="text"
                          size="small"
                          @click="moveDown(scope.row, scope.$index, 9)"
                        >
                          下移
                        </el-button>
                        <el-button
                          type="text"
                          size="small"
                          @click="
                            delMedicalRecordBoList(scope.row, scope.$index, 3)
                          "
                        >删除
                        </el-button
                        >
                      </template>
                    </el-table-column>
                  </el-table>
                </el-form-item>

                <el-form-item
                  label=""
                  prop="summaryTraditionalMedicalRecordList"
                >
                  <div class="r" style="justify-content: space-between">
                    <span></span>
                    <div>
                      <el-button
                        style="margin-bottom: 10px"
                        type="primary"
                        @click="getHISdirLog(6)"
                      >查询HIS中药饮片
                      </el-button
                      >
                      <el-button
                        style="
                          background-color: #b8dfea;
                          margin-bottom: 10px;
                          float: right;
                        "
                        @click="addMedicalRecordBoList(6)"
                      >添加一行
                      </el-button
                      >
                    </div>
                  </div>

                  <el-table
                    class="chushiyaowuzhenliao"
                    :data="yaoLiXiaoJieList.summaryTraditionalMedicalRecordList"
                    key="summaryTraditionalMedicalRecordList "
                    :cell-class-name="isRender"
                    ref="multipleTable6"
                    border
                  >
                    <el-table-column
                      prop="pillsName"
                      label="药物名称"
                      fixed
                      min-width="400"
                      align="center"
                    >
                      <template slot-scope="scope">
                        <el-autocomplete
                          style="width: 100%"
                          type="textarea"
                          autosize
                          class="require_des"
                          v-model="scope.row.pillsName"
                          :fetch-suggestions="querySearchAsync"
                          @select="handleSelect"
                        >
                          <template slot-scope="{ item }">
                            <el-tooltip
                              class="item"
                              effect="dark"
                              :content="item.value"
                              placement="right-end"
                            >
                              <div
                                class="query-item-text"
                                style="
                                  overflow: hidden;
                                  text-overflow: ellipsis;
                                  white-space: nowrap;
                                "
                              >
                                {{ item.value }}
                              </div>
                            </el-tooltip>
                          </template>
                        </el-autocomplete
                        >
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="pillsUsage"
                      label="用法用量"
                      min-width="130"
                    >
                      <template slot-scope="scope">
                        <el-input
                          type="textarea"
                          class="require_des"
                          v-model="scope.row.pillsUsage"
                        ></el-input>
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="beginDate"
                      label="起始日期"
                      align="center"
                      width="190"
                    >
                      <template slot-scope="scope">
                        <el-date-picker
                          v-model="scope.row.beginDate"
                          type="datetime"
                          clearable
                          format="yyyy-MM-dd"
                          value-format="yyyy-MM-dd HH:mm"
                          placeholder="请选择起始日期"
                          :picker-options="pickerOptions"
                          :disabledDate="disabledDate"
                        >
                        </el-date-picker>
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="endDate"
                      label="结束日期"
                      align="center"
                      width="190"
                    >
                      <template slot-scope="scope">
                        <el-date-picker
                          v-model="scope.row.endDate"
                          type="datetime"
                          clearable
                          format="yyyy-MM-dd"
                          value-format="yyyy-MM-dd HH:mm"
                          placeholder="请选择结束日期"
                        >
                        </el-date-picker>
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="address"
                      label="操作"
                      width="130"
                      fixed="right"
                      align="center"
                    >
                      <template slot-scope="scope">
                        <el-button
                          v-if="scope.$index > 0"
                          type="text"
                          size="small"
                          @click="moveUp(scope.row, scope.$index, 10)"
                        >
                          上移
                        </el-button>
                        <el-button
                          v-if="
                            scope.$index <
                            yaoLiXiaoJieList.summaryTraditionalMedicalRecordList
                              .length -
                              1
                          "
                          type="text"
                          size="small"
                          @click="moveDown(scope.row, scope.$index, 10)"
                        >
                          下移
                        </el-button>
                        <el-button
                          type="text"
                          size="small"
                          @click="
                            delMedicalRecordBoList(scope.row, scope.$index, 6)
                          "
                        >删除
                        </el-button
                        >
                      </template>
                    </el-table-column>
                  </el-table>
                </el-form-item>

                <el-form-item
                  label="合理用药情况汇总："
                  prop="reasonableMedicationSummary"
                >
                  <el-radio-group
                    v-model="yaoLiXiaoJieList.medicationSummaryOption"
                  >
                    <el-radio :label="true">有</el-radio>
                    <el-radio :label="false">无</el-radio>
                  </el-radio-group>
                  <el-input
                    v-if="yaoLiXiaoJieList.medicationSummaryOption == true"
                    v-model="yaoLiXiaoJieList.reasonableMedicationSummary"
                    type="textarea"
                    :rows="4"
                    placeholder="汇总患者住院医嘱前置审核中所有需要医师双签的内容"
                  />
                </el-form-item>
              </div>
              <div class="label" style="display: flex">
                <span
                  style="
                    font-size: 16px;
                    font-weight: 400;
                    margin-top: 5px;
                    width: 70px;
                    display: inline-block;
                    margin-right: 30px;
                  "
                >医保费用指标汇总：</span
                >
                <div style="width: 700px">
                  <el-form-item
                    label-width="350px"
                    label="住院患者药品使用金额占比"
                    prop="pharmaceuticalAmountPercent"
                  >
                    <el-input
                      v-model="yaoLiXiaoJieList.pharmaceuticalAmountPercent"
                      placeholder="请输入住院患者药品使用金额占比"
                    />
                  </el-form-item>
                  <el-form-item
                    label-width="350px"
                    label="住院患者自费药品使用金额占比"
                    prop="selfPharmaceuticalAmountPercent"
                  >
                    <el-input
                      v-model="yaoLiXiaoJieList.selfPharmaceuticalAmountPercent"
                      placeholder="请输入住院患者自费药品使用金额占比"
                    />
                  </el-form-item>
                </div>
              </div>
              <div class="label" style="display: flex">
                <span
                  style="
                    font-size: 16px;
                    font-weight: 400;
                    margin-top: 5px;
                    width: 97px;
                    display: inline-block;
                  "
                >其他药事管理指标汇总：</span
                >
                <div style="width: 700px">
                  <el-form-item
                    label-width="350px"
                    label="住院患者抗菌药物使用强度"
                    prop="antisepsisStrength"
                  >
                    <el-input
                      v-model="yaoLiXiaoJieList.antisepsisStrength"
                      placeholder="请输入住院患者抗菌药物使用强度"
                    />
                  </el-form-item>
                  <el-form-item
                    label-width="350px"
                    label="住院患者特殊使用级抗菌药物使用量占比"
                    prop="specialAntisepsisPercent"
                  >
                    <el-input
                      v-model="yaoLiXiaoJieList.specialAntisepsisPercent"
                      placeholder="请输入住院患者特殊使用级抗菌药物使用量占比"
                    />
                  </el-form-item>
                  <el-form-item
                    label-width="350px"
                    label="住院患者抗菌药物治疗前微生物检验样本送检情况"
                    prop="microorganismSample"
                  >
                    <el-input
                      v-model="yaoLiXiaoJieList.microorganismSample"
                      placeholder="请输入住院患者抗菌药物治疗前微生物检验样本送检情况"
                    />
                  </el-form-item>
                  <el-form-item
                    label-width="350px"
                    label="住院患者基本药物使用金额占比（不包括中药饮片）"
                    prop="baseMedicationAmountPercent"
                  >
                    <el-input
                      v-model="yaoLiXiaoJieList.baseMedicationAmountPercent"
                      placeholder="请输入住院患者基本药物使用金额占比（不包括中药饮片）"
                    />
                  </el-form-item>
                  <el-form-item
                    label-width="350px"
                    label="住院患者基本药物使用品种数情况（不包括中药饮片）"
                    prop="baseMedicationNumCondition"
                  >
                    <el-input
                      v-model="yaoLiXiaoJieList.baseMedicationNumCondition"
                      placeholder="请输入住院患者基本药物使用品种数情况（不包括中药饮片）"
                    />
                  </el-form-item>
                  <el-form-item
                    label-width="350px"
                    label="住院患者集中带量采购品种使用金额占比"
                    prop="purchaseAmountPercent"
                  >
                    <el-input
                      v-model="yaoLiXiaoJieList.purchaseAmountPercent"
                      placeholder="请输入住院患者集中带量采购品种使用金额占比"
                    />
                  </el-form-item>
                  <el-form-item
                    label-width="350px"
                    label="住院患者使用中药金额占比"
                    prop="traditionalPillsAmountPercent"
                  >
                    <el-input
                      v-model="yaoLiXiaoJieList.traditionalPillsAmountPercent"
                      placeholder="请输入住院患者使用中药金额占比"
                    />
                  </el-form-item>
                  <el-form-item
                    label-width="350px"
                    label="住院患者使用中药饮片金额占比"
                    prop="traditionalDrinkAmountPercent"
                  >
                    <el-input
                      v-model="yaoLiXiaoJieList.traditionalDrinkAmountPercent"
                      placeholder="请输入住院患者使用中药饮片金额占比"
                    />
                  </el-form-item>
                  <el-form-item
                    label-width="350px"
                    label="住院患者使用本院中药制剂金额占比"
                    prop="traditionalThisAmountPercent"
                  >
                    <el-input
                      v-model="yaoLiXiaoJieList.traditionalThisAmountPercent"
                      placeholder="请输入住院患者使用本院中药制剂金额占比"
                    />
                  </el-form-item>
                  <el-form-item
                    label-width="350px"
                    label="住院患者药品"
                    prop="pillsAmountPercent"
                  >
                    <el-input
                      v-model="yaoLiXiaoJieList.pillsAmountPercent"
                      placeholder="请输入住院患者药品"
                    />
                  </el-form-item>
                </div>
              </div>
            </el-form>
            <div class="r mt10" style="justify-content: space-between">
              <span></span>
              <div>
                <el-button
                  :loading="downAllyaoLiXiaoLoading"
                  type="primary"
                  @click="downAllyaoLiXiao"
                >下载完整药历
                </el-button
                >
                <el-button
                  v-hasPermi="['workstation:medicationSummary:export']"
                  :loading="downyaoLiXiaoJieListLoading"
                  type="primary"
                  @click="downyaoLiXiaoJieList"
                >下 载
                </el-button
                >
                <el-button type="success" @click="sumbityaoLi">提 交</el-button>
                <el-button
                  v-hasPermi="['workstation:medicationSummary:add']"
                  style="background-color: #1292b9; color: #fff; height: 36px"
                  @click="saveYaoLiXiaoJie"
                >保存
                </el-button
                >
              </div>
            </div>
          </div>
        </el-collapse-item>
      </el-collapse>
    </div>
    <div
      v-show="rightShow"
      class="rightBox"
      ref="rightBox"
      style="position: relative; width: 760px; right: 0"
    >
      <!-- 药历首页 -->
      <div
        v-loading="dataloading"
        :style="
          activeCard[0] == '2' ? 'margin-top: 150px;' : 'margin-top: 20px;'
        "
        v-if="
          activeCard.includes('1')
            ? true
            : activeCard.includes('2')
            ? true
            : false
        "
      >
        <h2 style="text-align: center; font-weight: 900">药历首页</h2>
        <div class="mb10 r">
          <span class="headTxt ml15">病区：</span>
          <span class="value">
            <treeselect
              style="width: 220px"
              disabled
              v-model="form.patientBaseInfoVo.deptId"
              :options="deptOptions"
              :show-count="true"
              placeholder=""
            />
          </span>
          <span class="headTxt">病案号：</span
          ><span class="value" style="height: 30px">{{
            form.patientBaseInfoVo.medicareNo
          }}</span>
          <span class="headTxt ml5">床号：</span
          ><span class="value" style="height: 30px">{{
            form.patientBaseInfoVo.bedNo
          }}</span>
          <span class="headTxt ml5">监护分级结果：</span
          ><span class="value" style="height: 30px">{{
            form.patientBaseInfoVo.guardianLevel == '0'
              ? '一级'
              : form.patientBaseInfoVo.guardianLevel == '1'
              ? '二级'
              : '三级'
          }}</span>
        </div>

        <table
          border="1"
          cellspacing="0"
          align="center"
          bordercolor="#ccc"
          width="730px"
        >
          <tr>
            <th align="center">姓名</th>
            <td align="center">
              {{ form.patientBaseInfoVo.patientName }}
            </td>
            <th align="center">性别</th>
            <td align="center">
              {{
                form.patientBaseInfoVo.patientSex == '1'
                  ? '男'
                  : form.patientBaseInfoVo.patientSex == '2'
                  ? '女'
                  : ''
              }}
            </td>
            <th width="60" align="center">年龄</th>
            <td align="center" width="100">
              {{ form.patientBaseInfoVo.patientAge }}
            </td>
            <th width="60" align="center">职业</th>
            <td align="center">
              {{
                form.patientBaseInfoVo.patientProfession
                  ? form.patientBaseInfoVo.patientProfession
                  : '无'
              }}
            </td>
            <th width="60" align="center">民族</th>
            <td align="center">
              {{ form.patientBaseInfoVo.nation }}
            </td>
          </tr>
          <tr>
            <th align="center">身高(cm)</th>
            <td align="center">
              {{ form.patientBaseInfoVo.patientHeight }}
            </td>
            <th align="center">体重(kg)</th>
            <td align="center" colspan="2">
              {{ form.patientBaseInfoVo.patientWeight }}
            </td>
            <th width="100" align="center">BMI(kg/m²)</th>
            <td colspan="2" align="center">
              {{ form.patientBaseInfoVo.patientBmi }}
            </td>
            <th align="center">费别</th>
            <td align="center">
              {{ feibie.dictLabel ? feibie.dictLabel : '' }}
            </td>
          </tr>
          <tr ref="zhusu">
            <th align="center">主诉</th>
            <td width="100" colspan="9">
              <div>{{ form.selfReported }}</div>
            </td>
          </tr>
          <tr>
            <th align="center">不良嗜好</th>
            <td width="100" colspan="9">
              <el-radio-group v-model="form.isHaveBadHobby">
                <el-radio :label="'0'" disabled>无</el-radio>
                <el-radio :label="'1'" disabled>有</el-radio>
              </el-radio-group>
              <div class="r buliangshihao" v-show="form.isHaveBadHobby == 1">
                <div class="r">
                  <el-radio v-model="form.isWine" :label="'1'" disabled
                  >酒
                  </el-radio
                  >
                  <div class="r" style="margin-right: 8px">
                    <el-input
                      style="width: 80px"
                      v-model="form.wineYear"
                      placeholder=""
                      disabled
                    />
                    <span class="ml5">年</span>
                  </div>
                  <div class="r">
                    <el-input
                      disabled
                      style="width: 80px"
                      v-model="form.wineAmountPerDay"
                      placeholder=""
                    />
                    <span class="ml5">两/天</span>
                  </div>
                </div>
                <div class="ml80">
                  <el-radio v-model="form.isSmoke" :label="'1'" disabled
                  >烟
                  </el-radio>
                  <div style="display: inline-block; margin-right: 8px">
                    <el-input
                      disabled
                      style="width: 80px"
                      v-model="form.smokeYear"
                      placeholder=""
                    />
                    <span class="ml5 mr5">年</span>
                    <el-input
                      disabled
                      style="width: 80px"
                      v-model="form.smokeAmountPerDay"
                      placeholder=""
                    />
                    <span class="ml5">支/天</span>
                  </div>
                </div>
              </div>
              <div
                style="display: inline-block"
                v-show="form.isHaveBadHobby == 1"
              >
                <el-radio v-model="form.isEat" :label="'1'" disabled
                >饮食
                </el-radio
                >
                <div class="buliangshihao" style="display: inline-block">
                  <el-input
                    disabled
                    style="width: 285px"
                    v-model="form.eatBadHobby"
                    placeholder=""
                  />
                </div>
              </div>
              <div
                style="display: inline-block; margin-left: 5px"
                v-show="form.isHaveBadHobby == 1"
              >
                <el-radio v-model="form.isOther" :label="'1'" disabled
                >其他
                </el-radio
                >
                <div class="buliangshihao" style="display: inline-block">
                  <el-input
                    disabled
                    style="width: 285px"
                    v-model="form.otherBadHobby"
                    placeholder=""
                  />
                </div>
              </div>
            </td>
          </tr>
          <tr>
            <th align="center">现病史及现病史用药汇总</th>
            <td colspan="9" style="padding: 0px">
              <div class="buliangshihao" style="padding: 10px">
                {{ form.medicalHistoryNow }}
              </div>
              <div
                class="yaoxuejianhu"
                v-if="form.medicationSummaryOption1 == true"
              >
                <table align="center" width="654px" cellspacing="0">
                  <tr>
                    <th style="border-top: 1px solid #ccc">原发病</th>
                    <th style="border-top: 1px solid #ccc">药物名称</th>
                    <th style="border-top: 1px solid #ccc">用法用量</th>
                    <th style="border-top: 1px solid #ccc">最后用药时间</th>
                    <th style="border-top: 1px solid #ccc">是否继续使用</th>
                  </tr>
                  <template
                    v-if="
                      form.nowMedicalRecordVoList &&
                      form.nowMedicalRecordVoList.length > 0
                    "
                  >
                    <tr
                      v-for="(item, index) in form.nowMedicalRecordVoList"
                      :key="index"
                    >
                      <td
                        align="center"
                        :style="
                          index == form.nowMedicalRecordVoList.length - 1
                            ? 'border-bottom: none !important;'
                            : ''
                        "
                      >
                        {{ item.purpose }}
                      </td>
                      <td
                        align="center"
                        :style="
                          index == form.nowMedicalRecordVoList.length - 1
                            ? 'border-bottom: none !important;'
                            : ''
                        "
                      >
                        {{ item.pillsName }}
                      </td>
                      <td
                        align="center"
                        :style="
                          index == form.nowMedicalRecordVoList.length - 1
                            ? 'border-bottom: none !important;'
                            : ''
                        "
                      >
                        {{ item.amount }}
                      </td>
                      <td
                        align="center"
                        :style="
                          index == form.nowMedicalRecordVoList.length - 1
                            ? 'border-bottom: none !important;'
                            : ''
                        "
                      >
                        {{ item.pillsCycle }}
                      </td>
                      <td
                        align="center"
                        :style="
                          index == form.nowMedicalRecordVoList.length - 1
                            ? 'border-bottom: none !important;'
                            : ''
                        "
                      >
                        {{
                          item.isContinue == 'Y'
                            ? '是'
                            : item.isContinue == 'N'
                            ? '否'
                            : ''
                        }}
                      </td>
                    </tr>
                  </template>
                  <template v-else>
                    <tr
                      align="center"
                      style="padding: 5px; border-bottom: none"
                    >
                      <td
                        align="center"
                        style="color: #ccc; border-bottom: none !important"
                        colspan="5"
                      >
                        暂无数据
                      </td>
                    </tr>
                  </template>
                </table>
              </div>
              <div v-else style="padding: 0 10px 10px 10px">
                现病史用药汇总无数据
              </div>
            </td>
          </tr>
          <tr>
            <th width="100" align="center">既往病史及既往病史用药汇总</th>
            <td width="100" colspan="9" style="padding: 0px">
              <div class="" style="padding: 10px">
                {{ form.medicalHistoryBefore }}
              </div>
              <div
                class="yaoxuejianhu"
                v-if="form.medicationSummaryOption2 == true"
              >
                <table align="center" width="654px" cellspacing="0">
                  <tr>
                    <th style="border-top: 1px solid #ccc">原发病</th>
                    <th style="border-top: 1px solid #ccc">药物名称</th>
                    <th style="border-top: 1px solid #ccc">用法用量</th>
                    <th style="border-top: 1px solid #ccc">最后用药时间</th>
                    <th style="border-top: 1px solid #ccc">是否继续使用</th>
                  </tr>
                  <template
                    v-if="
                      form.beforeMedicalRecordVoList &&
                      form.beforeMedicalRecordVoList.length > 0
                    "
                  >
                    <tr
                      v-for="(item, index) in form.beforeMedicalRecordVoList"
                      :key="index"
                    >
                      <td
                        align="center"
                        :style="
                          index == form.beforeMedicalRecordVoList.length - 1
                            ? 'border-bottom: none !important;'
                            : ''
                        "
                      >
                        {{ item.purpose }}
                      </td>
                      <td
                        align="center"
                        :style="
                          index == form.beforeMedicalRecordVoList.length - 1
                            ? 'border-bottom: none !important;'
                            : ''
                        "
                      >
                        {{ item.pillsName }}
                      </td>
                      <td
                        align="center"
                        :style="
                          index == form.beforeMedicalRecordVoList.length - 1
                            ? 'border-bottom: none !important;'
                            : ''
                        "
                      >
                        {{ item.amount }}
                      </td>
                      <td
                        align="center"
                        :style="
                          index == form.beforeMedicalRecordVoList.length - 1
                            ? 'border-bottom: none !important;'
                            : ''
                        "
                      >
                        {{ item.pillsCycle }}
                      </td>
                      <td
                        align="center"
                        :style="
                          index == form.beforeMedicalRecordVoList.length - 1
                            ? 'border-bottom: none !important;'
                            : ''
                        "
                      >
                        {{
                          item.isContinue == 'Y'
                            ? '是'
                            : item.isContinue == 'N'
                            ? '否'
                            : ''
                        }}
                      </td>
                    </tr>
                  </template>
                  <template v-else>
                    <tr
                      align="center"
                      style="padding: 5px; border-bottom: none"
                    >
                      <td
                        align="center"
                        style="color: #ccc; border-bottom: none !important"
                        colspan="5"
                      >
                        暂无数据
                      </td>
                    </tr>
                  </template>
                </table>
              </div>
              <div v-else style="padding: 0 10px 10px 10px">
                既往病史用药汇总无数据
              </div>
            </td>
          </tr>
          <tr>
            <th align="center">过敏史及处置史</th>
            <td width="100" colspan="9">
              <el-radio-group
                v-model="form.isHaveAllergy"
                @change="handleisHaveAllergy"
                disabled
              >
                <el-radio :label="'0'">无</el-radio>
                <el-radio :label="'1'">有</el-radio>
              </el-radio-group>
              <div class="buliangshihao" v-show="form.isHaveAllergy == 1">
                <div class="r">
                  <span class="mr10">怀疑药物/食物名称</span>
                  <el-input
                    style="width: 250px"
                    disabled
                    v-model="form.doubtPillsOrFoodName"
                    placeholder=""
                  />
                </div>
                <div class="r mb10">
                  <span class="mr10">主要ADR临床表现</span>
                  <el-input
                    style="width: 250px"
                    disabled
                    v-model="form.adrClinicFeature"
                    placeholder=""
                  />
                </div>
                <div class="r">
                  <span style="display: inline-block; width: 190px"
                  >处理措施及结果</span
                  >
                  <el-checkbox-group v-model="form.disposeAndResult" disabled>
                    <el-row>
                      <el-col
                        :span="8"
                        v-for="item in disposeResult"
                        :key="item.id"
                      >
                        <el-checkbox
                          style="font-size: 13px"
                          :label="item.dictValue"
                          class="region-list-item"
                        >{{
                            item.dictLabel
                          }}
                          <el-input
                            v-if="item.dictLabel == '其他'"
                            style="width: 285px; display: inline"
                            v-model="form.otherDisposeAndResult"
                            placeholder=""
                          />
                        </el-checkbox>
                      </el-col>
                    </el-row>
                  </el-checkbox-group>
                </div>
                <div class="r">
                  <el-radio
                    class="mr10"
                    v-model="form.isOtherDisposeAndResult"
                    :label="'1'"
                    disabled
                  >其他
                  </el-radio
                  >
                  <el-input
                    disabled
                    style="width: 250px"
                    v-model="form.otherDisposeAndResult"
                    placeholder=""
                  />
                </div>
              </div>
            </td>
          </tr>
          <tr>
            <th width="100" align="center">家族史</th>
            <td width="100" colspan="9">
              <div>{{ form.familyHistory }}</div>
            </td>
          </tr>
          <tr>
            <th width="100" align="center">个人史</th>
            <td width="100" colspan="9">
              <div>{{ form.personHistory }}</div>
            </td>
          </tr>
          <tr>
            <th width="100" align="center">入院诊断</th>
            <td colspan="9">
              <!-- <div class="b">出院诊断：</div> -->
              <div style="display: flex; justify-content: space-between">
                <div style="width: 86px">西医诊断：</div>
                <div style="width: 92%">
                  {{ form.admittingDiagnosisWestern }}
                </div>
              </div>
              <div style="display: flex; margin-top: 5px">
                <span>中医诊断：</span>
                <div>
                  <div
                    v-for="(item, index) in form.traditionalDiagnosisVoList"
                    :key="index"
                  >
                    <div
                      :style="index !== 0 ? 'margin-top: 7px' : ''"
                      style="display: flex"
                    >
                      <div>{{ index + 1 }}、</div>
                      <div>
                        <span>病：</span>
                        {{ item.illnessName }}
                        <div style="margin-top: 5px">
                          <span>证：</span>
                          {{ item.patternOfSyndrome }}
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </td>
          </tr>
          <tr>
            <th width="100" align="center">初始药物治疗方案汇总</th>
            <td colspan="9" style="padding: 0px">
              <div class="yaoxuejianhu">
                <table align="center" width="654px" cellspacing="0">
                  <tr>
                    <!-- <th style="width: 85px">用药目的</th> -->
                    <th>药物名称(通用名称)</th>
                    <th style="width: 85px">单次剂量</th>
                    <th style="width: 85px">用法</th>
                    <th style="width: 85px">频次</th>
                    <th style="width: 105px">起始日期</th>
                  </tr>
                  <template
                    v-if="
                      form.initalMedicalRecordVoList &&
                      form.initalMedicalRecordVoList.length > 0
                    "
                  >
                    <tr
                      v-for="(item, index) in form.initalMedicalRecordVoList"
                      :key="index"
                    >
                      <!-- <td align="center">{{ item.purpose }}</td> -->
                      <td align="center">{{ item.pillsName }}</td>
                      <td align="center">{{ item.amountPer }}</td>
                      <td align="center">{{ item.pillsUsage }}</td>
                      <td align="center">{{ item.frequency }}</td>
                      <td align="center">
                        {{ item.beginDate ? item.beginDate.split(' ')[0] : '' }}
                      </td>
                    </tr>
                  </template>
                  <template v-else>
                    <tr
                      align="center"
                      style="padding: 5px; border-bottom: none"
                    >
                      <td
                        align="center"
                        style="color: #ccc; border-bottom: none !important"
                        colspan="5"
                      >
                        暂无数据
                      </td>
                    </tr>
                  </template>
                </table>
              </div>
              <div class="yaoxuejianhu mt10">
                <table align="center" width="654px" cellspacing="0">
                  <tr>
                    <!-- <th style="border-top: 1px solid #ccc; width: 85px">
                      用药目的
                    </th> -->
                    <th style="border-top: 1px solid #ccc">
                      药物名称(通用名称)
                    </th>
                    <th style="border-top: 1px solid #ccc; width: 85px">
                      用法用量
                    </th>
                    <th style="border-top: 1px solid #ccc; width: 105px">
                      起始日期
                    </th>
                  </tr>
                  <template
                    v-if="
                      form.initTraditionalMedicalList &&
                      form.initTraditionalMedicalList.length > 0
                    "
                  >
                    <tr
                      v-for="(item, index) in form.initTraditionalMedicalList"
                      :key="index + 'haha'"
                    >
                      <td
                        align="center"
                        style="white-space: pre-wrap"
                        :style="
                          index == form.initTraditionalMedicalList.length - 1
                            ? 'border-bottom:none !important'
                            : ''
                        "
                      >
                        {{ item.pillsName }}
                      </td>
                      <td
                        align="center"
                        :style="
                          index == form.initTraditionalMedicalList.length - 1
                            ? 'border-bottom:none !important'
                            : ''
                        "
                      >
                        {{ item.pillsUsage }}
                      </td>
                      <td
                        align="center"
                        :style="
                          index == form.initTraditionalMedicalList.length - 1
                            ? 'border-bottom:none !important'
                            : ''
                        "
                      >
                        {{ item.beginDate ? item.beginDate.split(' ')[0] : '' }}
                      </td>
                    </tr>
                  </template>
                  <template v-else>
                    <tr
                      align="center"
                      style="padding: 5px; border-bottom: none"
                    >
                      <td
                        align="center"
                        style="color: #ccc; border-bottom: none !important"
                        colspan="3"
                      >
                        暂无数据
                      </td>
                    </tr>
                  </template>
                </table>
              </div>
              <el-table
                v-if="false"
                class="chushiyaowuzhenliao"
                :data="form.initalMedicalRecordVoList"
                key="initalMedicalRecordVoList"
                style="width: 100%"
                :cell-class-name="isRender"
                ref="multipleTable2"
                row-key="orderItemId"
                border
                :default-expand-all="false"
                :tree-props="{
                  children: 'childMedicalRecordList',
                  hasChildren: 'hasChildren',
                }"
              >

                <el-table-column
                  prop="pillsName"
                  label="药物名称"
                  fixed
                  align="center"
                >
                </el-table-column>
                <el-table-column
                  align="center"
                  prop="amountPer"
                  label="单次剂量"
                >
                </el-table-column>
                <el-table-column align="center" prop="pillsUsage" label="用法">
                </el-table-column>
                <el-table-column
                  prop="purpose"
                  label="用药目的"
                  fixed
                  align="center"
                >
                </el-table-column>
                <el-table-column align="center" prop="frequency" label="频次">
                </el-table-column>
                <el-table-column
                  prop="beginDate"
                  label="起始日期"
                  align="center"
                >
                </el-table-column>
              </el-table>
            </td>
          </tr>
          <tr>
            <th width="100" align="center">药学评估结果</th>
            <td width="100" colspan="9">
              <div class="pl5">
                <div>
                  患者一般情况评估结果：{{ queryParams.generalConditionScore }}
                </div>
              </div>
              <div class="pl5 mt10">
                <div>
                  患者生活方式评估结果：{{ queryParams.liveStyleScore }}
                </div>
              </div>
              <div class="pl5 mt10">
                <div>
                  既往用药依从性评估结果：{{ queryParams.eatPillsHobbyScore }}
                </div>
              </div>
              <div class="pl5 mt10">
                <div>
                  一般医药知识评估结果：{{ queryParams.generalPillsScore }}
                </div>
                <div class="mt10">总分：{{ queryParams.totalScore }}</div>
              </div>
              <div class="mt10 pl5 r">
                <div>药学评估结论：</div>
                <span
                  style="font-size: 16px"
                  v-if="queryParams.selfCareAbilityLabel"
                >
                  <div>
                    {{
                      queryParams.totalScore > 80
                        ? '良好'
                        : queryParams.totalScore >= 60
                        ? '合格'
                        : '不合格'
                    }}
                  </div>
                </span>
              </div>
            </td>
          </tr>
          <tr>
            <th width="100" align="center">药学监护计划</th>
            <td width="100" colspan="9">
              <div class="b" style="margin-bottom: 5px">药学监护计划</div>
              <span style="white-space: pre-wrap">{{
                  form.medicalGuardianSchedule
                }}</span>
            </td>
          </tr>
        </table>
        <div style="float: right; margin-top: 20px">
          <el-button
            :loading="downAllyaoLiXiaoLoading"
            type="primary"
            @click="downAllyaoLiXiao"
          >下载完整药历
          </el-button
          >
        </div>
      </div>

      <!-- 药学监护记录 -->
      <div
        style="width: 730px; margin-top: 300px; margin-left: 20px"
        v-if="activeCard.includes('4') ? true : false"
      >
        <h3 style="text-align: center; font-weight: 900; font-size: 19px">
          药学监护记录
        </h3>
        <div
          style="border: 1px solid #ccc"
          v-if="
            pharmaceuticalCare.pharmaceuticalCareDetailVoList &&
            pharmaceuticalCare.pharmaceuticalCareDetailVoList.length > 0
          "
        >
          <div
            :class="index !== 0 ? '' : ''"
            v-for="(
              item, index
            ) in pharmaceuticalCare.pharmaceuticalCareDetailVoList"
            :key="index"
            class="buliangshihao"
          >
            <div class="" style="padding: 10px">
              <span>日期：{{ item.careDate }}</span
              ><span class="ml15">入院第 {{ item.inHospitalDays }} 天</span>
              <span class="ml15">药学监护级别：</span
              >
              <span>
                {{
                  {
                    0: '一级',
                    1: '二级',
                    2: '三级'
                  }[item.guardianLevel] || ''
                }}
            </span>
            </div>
            <div class="" style="padding: 10px">
              <span class="mb5" style="display: inline-block">生命体征：</span>
              <div v-if="item.vitalSigns" style="white-space: pre-wrap">
                {{ item.vitalSigns }}
              </div>
              <div v-else>体温、心率、呼吸、血压为必填项</div>
            </div>
            <div class="" style="padding: 10px">
              <span class="mb5" style="display: inline-block"
              >监护计划执行情况：</span
              >
              <div v-if="item.executiveCondition" style="white-space: pre-wrap">
                {{ item.executiveCondition }}
              </div>
              <div v-else>
                根据制定的监护计划，记录患者的病情变化、合理用药情况、医保费用和其他药事管理指标变化情况等
              </div>
            </div>
            <div class="">
              <span class="mb5 ml10" style="display: inline-block"
              >药物治疗方案调整：</span
              >
              <div
                class="yaoxuejianhu"
                v-if="item.medicationSummaryOption1 == true"
              >
                <table align="center" width="730" cellspacing="0">
                  <tr>
                    <th
                      align="center"
                      style="border-top: 1px solid #ccc; width: 85px"
                    >
                      用药调整
                    </th>
                    <th align="center" style="border-top: 1px solid #ccc">
                      药物名称
                    </th>
                    <th style="border-top: 1px solid #ccc; width: 85px">
                      单次剂量
                    </th>
                    <th style="border-top: 1px solid #ccc; width: 85px">
                      用法
                    </th>
                    <th style="border-top: 1px solid #ccc; width: 85px">
                      频次
                    </th>
                    <th
                      align="center"
                      style="border-top: 1px solid #ccc; width: 105px"
                    >
                      起始日期
                    </th>
                  </tr>
                  <template
                    v-if="
                      item.careDetailMedicalList &&
                      item.careDetailMedicalList.length > 0
                    "
                  >
                    <tr
                      v-for="(val, index) in item.careDetailMedicalList"
                      :key="index"
                    >
                      <td align="center">{{ val.purpose }}</td>
                      <td align="center">{{ val.pillsName }}</td>
                      <td align="center">{{ val.amountPer }}</td>
                      <td align="center">{{ val.pillsUsage }}</td>
                      <td align="center">{{ val.frequency }}</td>
                      <td align="center">
                        {{ val.beginDate ? val.beginDate.split(' ')[0] : '' }}
                      </td>
                    </tr>
                  </template>
                  <template v-else>
                    <tr align="center" style="padding: 5px">
                      <td
                        align="center"
                        style="color: #ccc; border-bottom: none !important"
                        colspan="6"
                      >
                        暂无数据
                      </td>
                    </tr>
                  </template>
                </table>
              </div>
              <div
                class="yaoxuejianhu mt20"
                v-if="item.medicationSummaryOption2 == true"
              >
                <table align="center" width="730px" cellspacing="0">
                  <tr>
                    <th style="border-top: 1px solid #ccc; width: 85px">
                      用药调整
                    </th>
                    <th style="border-top: 1px solid #ccc; width: 60%">
                      药物名称(通用名称)
                    </th>
                    <th style="border-top: 1px solid #ccc">用法用量</th>
                    <th style="border-top: 1px solid #ccc">起始日期</th>
                  </tr>
                  <template
                    v-if="
                      item.traditionalMedicalList &&
                      item.traditionalMedicalList.length > 0
                    "
                  >
                    <tr
                      v-for="(value, index) in item.traditionalMedicalList"
                      :key="index + 'xihaha'"
                    >
                      <td align="center">
                        {{ value.purpose ? value.purpose : '' }}
                      </td>
                      <td align="center" style="white-space: pre-wrap">
                        {{ value.pillsName }}
                      </td>
                      <td align="center">{{ value.pillsUsage }}</td>
                      <td align="center">
                        {{
                          value.beginDate ? value.beginDate.split(' ')[0] : ''
                        }}
                      </td>
                    </tr>
                  </template>
                  <template v-else>
                    <tr align="center" style="padding: 5px">
                      <td align="center" style="color: #ccc" colspan="4">
                        暂无数据
                      </td>
                    </tr>
                  </template>
                </table>
              </div>
            </div>
            <div class="" style="padding: 10px" v-show="item.carePlanAdjustmentOption == 'true'">
              <span class="mb5" style="display: inline-block"
              >药物监护计划调整：</span
              >
              <div style="white-space: pre-wrap">
                {{ item.carePlanAdjustment }}
              </div>
            </div>
            <div class="" style="padding: 10px" v-if="item.pillsEducationOption == 'true'">
              <span class="mb5" style="display: inline-block">用药教育：</span>
              <div style="white-space: pre-wrap">
                {{ item.pillsEducation }}
              </div>
            </div>
            <div class="" style="padding: 10px" v-if="item.medicationSummaryOption3 == 'true'">
              <span class="mb5" style="display: inline-block">用药建议：</span>
              <div style="white-space: pre-wrap">
                {{ item.pillsSuggest }}
              </div>
            </div>
          </div>
        </div>
        <div style="border: 1px solid #ccc; padding: 10px" v-else>
          <el-empty :image-size="100"></el-empty>
        </div>
      </div>

      <!-- 出院用药教育 -->
      <div
        style="width: 730px; margin-top: 10px; margin-left: 20px"
        v-if="activeCard.includes('4') ? true : false"
      >
        <h3 style="text-align: center; font-weight: 900; font-size: 19px">
          出院用药教育
        </h3>
        <div style="border: 1px solid #ccc">
          <div class="yaoxuejianhu">
            <h4 class="b ml10" style="margin-top: 10px; margin-bottom: 10px">
              出院用药：
            </h4>
            <table v-if="pharmaceuticalCare.dischargePillsOption == 'true'" align="center" width="730px"
                   cellspacing="0"
            >
              <tr>
                <th style="border-top: 1px solid #ccc">药物名称(通用名称)</th>
                <th style="width: 85px; border-top: 1px solid #ccc">
                  单次剂量
                </th>
                <th style="width: 85px; border-top: 1px solid #ccc">用法</th>
                <th style="width: 85px; border-top: 1px solid #ccc">频次</th>
                <th style="width: 105px; border-top: 1px solid #ccc">
                  用药周期
                </th>
              </tr>
              <template
                v-if="
                  pharmaceuticalCare.educWestMedicalRecordList &&
                  pharmaceuticalCare.educWestMedicalRecordList.length > 0
                "
              >
                <tr
                  v-for="(
                    item, index
                  ) in pharmaceuticalCare.educWestMedicalRecordList"
                  :key="index"
                >
                  <td align="center">{{ item.pillsName }}</td>
                  <td align="center">{{ item.amountPer }}</td>
                  <td align="center">{{ item.pillsUsage }}</td>
                  <td align="center">{{ item.frequency }}</td>
                  <td align="center">
                    {{ item.beginDate ? item.beginDate.split(' ')[0] : '' }}
                  </td>
                </tr>
              </template>
              <template v-else>
                <tr align="center" style="padding: 5px; border-bottom: none">
                  <td
                    align="center"
                    style="color: #ccc; border-bottom: none !important"
                    colspan="5"
                  >
                    暂无数据
                  </td>
                </tr>
              </template>
            </table>
            <table
              v-if="pharmaceuticalCare.dischargePillsOption == 'true'"
              align="center"
              width="730px"
              cellspacing="0"
              style="margin-top: 15px"
            >
              <tr>
                <th style="border-top: 1px solid #ccc">药物名称(通用名称)</th>
                <th style="border-top: 1px solid #ccc; width: 85px">
                  用法用量
                </th>
                <th style="border-top: 1px solid #ccc; width: 105px">
                  用药周期
                </th>
                <th style="border-top: 1px solid #ccc; width: 105px">
                  结束日期
                </th>
              </tr>
              <template
                v-if="
                  pharmaceuticalCare.educTraditionalMedicalRecordList &&
                  pharmaceuticalCare.educTraditionalMedicalRecordList.length > 0
                "
              >
                <tr
                  v-for="(
                    item, index
                  ) in pharmaceuticalCare.educTraditionalMedicalRecordList"
                  :key="index + 'haha'"
                >
                  <td align="center" style="white-space: pre-wrap">
                    {{ item.pillsName }}
                  </td>
                  <td align="center">{{ item.pillsUsage }}</td>
                  <td align="center">{{ item.pillsCycle }}</td>
                  <td align="center">
                    {{ item.endDate ? item.endDate.split(' ')[0] : '' }}
                  </td>
                </tr>
              </template>
              <template v-else>
                <tr align="center" style="padding: 5px; border-bottom: none">
                  <td
                    align="center"
                    style="color: #ccc; border-bottom: none !important"
                    colspan="4"
                  >
                    暂无数据
                  </td>
                </tr>
              </template>
            </table>
          </div>
          <div style="padding: 10px">
            <div>
              根据患者出院时病情和用药情况详实记录对患者的用药教育内容。
            </div>
            <div class="mt5 mb5">主要包含以下几方面:</div>
            <el-input
              disabled
              type="textarea"
              :rows="8"
              placeholder="①随访复查指标;②生活方式;③用药注意事项"
              v-model="pharmaceuticalCare.dischargePharmacyEducation"
            />
          </div>
          <div style="float: right; margin-top: 20px">
            <el-button
              :loading="downAllyaoLiXiaoLoading"
              type="primary"
              @click="downAllyaoLiXiao"
            >下载完整药历
            </el-button
            >
          </div>
        </div>
      </div>

      <!-- 药学监护小结 -->
      <div
        style="width: 730px; margin-top: 420px; margin-left: 20px"
        v-if="activeCard.includes('5') ? true : false"
      >
        <h3 style="text-align: center; font-weight: 900; font-size: 19px">
          药历小结
        </h3>
        <div>
          <div
            style="
              border-top: 1px solid #ccc;
              border-left: 1px solid #ccc;
              border-right: 1px solid #ccc;
              padding: 10px;
            "
          >
            <span>入院日期</span
            ><span class="ml10">{{
              parseTime(form.patientBaseInfoVo.admissionTime, '{y}-{m}-{d}')
            }}</span>
            <span class="ml20">出院日期</span
            ><span class="ml10">{{
              parseTime(form.patientBaseInfoVo.dischargeTime, '{y}-{m}-{d}')
            }}</span>
            <span class="ml20">住院天数</span
            ><span class="ml10">{{ yaoLiXiaoJieList.inHospitalDays }} 天</span>
          </div>
          <table
            border="1"
            cellspacing="0"
            align="center"
            width="730"
            bordercolor="#ccc"
          >
            <tr>
              <th width="65">出院记录</th>
              <td>
                <div class="b">出院诊断：</div>
                <div style="display: flex; margin-left: 20px; margin-top: 10px">
                  <div style="width: 86px">西医诊断：</div>
                  <div style="width: 92%">
                    {{ yaoLiXiaoJieList.admittingDiagnosisWestern }}
                  </div>
                </div>
                <div style="display: flex; margin-left: 20px; margin-top: 10px">
                  <span>中医诊断：</span>
                  <div>
                    <div
                      v-for="(
                        item, index
                      ) in yaoLiXiaoJieList.traditionalDiagnosisVoList"
                      :key="index"
                    >
                      <div
                        :style="index !== 0 ? 'margin-top: 7px' : ''"
                        style="display: flex"
                      >
                        <div>{{ index + 1 }}、</div>
                        <div>
                          <span>病：</span>
                          {{ item.illnessName }}
                          <div style="margin-top: 5px">
                            <span>证：</span>
                            {{ item.patternOfSyndrome }}
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </td>
            </tr>
            <tr>
              <th>住院期间治疗药物汇总</th>
              <td style="padding: 0px">
                <el-table
                  v-if="false"
                  class="chushiyaowuzhenliao"
                  :data="yaoLiXiaoJieList.medicalRecordVoList"
                  key="medicalRecordVoList"
                  style="width: 100%"
                  :cell-class-name="isRender"
                  ref="multipleTable2"
                  row-key="orderItemId"
                  border
                  :default-expand-all="false"
                  :tree-props="{
                    children: 'childMedicalRecordList',
                    hasChildren: 'hasChildren',
                  }"
                >
                  <el-table-column
                    prop="pillsName"
                    label="药物名称"
                    fixed
                    align="center"
                  >
                  </el-table-column>
                  <el-table-column
                    align="center"
                    prop="amountPer"
                    label="单次剂量"
                  >
                  </el-table-column>
                  <el-table-column
                    align="center"
                    prop="pillsUsage"
                    label="用法"
                  >
                  </el-table-column>
                  <el-table-column
                    prop="purpose"
                    label="用药目的"
                    fixed
                    align="center"
                  >
                  </el-table-column>
                  <el-table-column align="center" prop="frequency" label="频次">
                  </el-table-column>
                  <el-table-column
                    prop="beginDate"
                    label="开始日期"
                    align="center"
                  >
                  </el-table-column>
                  <el-table-column
                    prop="endDate"
                    label="结束日期"
                    align="center"
                  >
                  </el-table-column>
                </el-table>
                <div class="yaoxuejianhu">
                  <table align="center" width="663" cellspacing="0">
                    <tr>
                      <th align="center">药物名称(通用名称)</th>
                      <th>单次剂量</th>
                      <th>用法</th>
                      <th>频次</th>
                      <th align="center">起止日期</th>
                    </tr>
                    <template
                      v-if="
                        yaoLiXiaoJieList.medicalRecordVoList &&
                        yaoLiXiaoJieList.medicalRecordVoList.length > 0
                      "
                    >
                      <tr
                        v-for="(
                          item, index
                        ) in yaoLiXiaoJieList.medicalRecordVoList"
                        :key="index"
                      >
                        <td align="center">{{ item.pillsName }}</td>
                        <td align="center">{{ item.amountPer }}</td>
                        <td align="center">{{ item.pillsUsage }}</td>
                        <td align="center">{{ item.frequency }}</td>
                        <td align="center">
                          {{
                            item.beginDate && item.endDate
                              ? item.beginDate.split(' ')[0] +
                              '—' +
                              item.endDate.split(' ')[0]
                              : ''
                          }}
                        </td>
                      </tr>
                    </template>
                    <template v-else>
                      <tr
                        align="center"
                        style="padding: 5px; border-bottom: none"
                      >
                        <td
                          align="center"
                          style="color: #ccc; border-bottom: none !important"
                          colspan="5"
                        >
                          暂无数据
                        </td>
                      </tr>
                    </template>
                  </table>
                </div>
                <div class="yaoxuejianhu mt20">
                  <table align="center" width="663px" cellspacing="0">
                    <tr>
                      <th style="border-top: 1px solid #ccc; width: 60%">
                        药物名称(通用名称)
                      </th>
                      <th style="border-top: 1px solid #ccc">用法用量</th>
                      <th style="border-top: 1px solid #ccc">起始日期</th>
                    </tr>
                    <template
                      v-if="
                        yaoLiXiaoJieList.summaryTraditionalMedicalRecordList &&
                        yaoLiXiaoJieList.summaryTraditionalMedicalRecordList
                          .length > 0
                      "
                    >
                      <tr
                        v-for="(
                          item, index
                        ) in yaoLiXiaoJieList.summaryTraditionalMedicalRecordList"
                        :key="index + 'haha'"
                      >
                        <td
                          align="center"
                          style="white-space: pre-wrap"
                          :style="
                            index ==
                            yaoLiXiaoJieList.summaryTraditionalMedicalRecordList
                              .length -
                              1
                              ? 'border-bottom: none !important;'
                              : ''
                          "
                        >
                          {{ item.pillsName }}
                        </td>
                        <td
                          align="center"
                          :style="
                            index ==
                            yaoLiXiaoJieList.summaryTraditionalMedicalRecordList
                              .length -
                              1
                              ? 'border-bottom: none !important;'
                              : ''
                          "
                        >
                          {{ item.pillsUsage }}
                        </td>
                        <td
                          align="center"
                          :style="
                            index ==
                            yaoLiXiaoJieList.summaryTraditionalMedicalRecordList
                              .length -
                              1
                              ? 'border-bottom: none !important;'
                              : ''
                          "
                        >
                          {{
                            item.beginDate && item.endDate
                              ? item.beginDate.split(' ')[0] +
                              '—' +
                              item.endDate.split(' ')[0]
                              : ''
                          }}
                        </td>
                      </tr>
                    </template>
                    <template v-else>
                      <tr
                        align="center"
                        style="padding: 5px; border-bottom: none"
                      >
                        <td
                          align="center"
                          style="color: #ccc; border-bottom: none !important"
                          colspan="3"
                        >
                          暂无数据
                        </td>
                      </tr>
                    </template>
                  </table>
                </div>
              </td>
            </tr>
            <tr>
              <th>合理用药情况汇总</th>
              <td>
                <template v-if="yaoLiXiaoJieList.medicationSummaryOption">
                  <div>{{ yaoLiXiaoJieList.reasonableMedicationSummary }}</div>
                  <span v-if="!yaoLiXiaoJieList.reasonableMedicationSummary"
                  >汇总患者住院医嘱前置审核中所有需要医师双签的内容</span
                  >
                </template>
              </td>
            </tr>
            <tr>
              <th>医保费用指标汇总</th>
              <td style="padding: 0px">
                <div class="yaoxuejianhu">
                  <table align="center" width="663" cellspacing="0">
                    <tr align="center">
                      <th width="420">指标</th>
                      <th>结果</th>
                    </tr>
                    <tr align="center">
                      <td>住院患者药品使用金额占比</td>
                      <td>
                        {{ yaoLiXiaoJieList.pharmaceuticalAmountPercent }}
                      </td>
                    </tr>
                    <tr align="center">
                      <td style="border-bottom: none !important">
                        住院患者自费药品使用金额占比
                      </td>
                      <td style="border-bottom: none !important">
                        {{ yaoLiXiaoJieList.selfPharmaceuticalAmountPercent }}
                      </td>
                    </tr>
                  </table>
                </div>
              </td>
            </tr>
            <tr>
              <th>其他药事管理指标汇总</th>
              <td style="padding: 0px">
                <div class="yaoxuejianhu">
                  <table align="center" width="663" cellspacing="0">
                    <tr align="center">
                      <th width="420">指标</th>
                      <th>结果</th>
                    </tr>
                    <tr align="center">
                      <td>住院患者抗菌药物使用强度</td>
                      <td>{{ yaoLiXiaoJieList.antisepsisStrength }}</td>
                    </tr>
                    <tr align="center">
                      <td>住院患者特殊使用级抗菌药物使用量占比</td>
                      <td>{{ yaoLiXiaoJieList.specialAntisepsisPercent }}</td>
                    </tr>
                    <tr align="center">
                      <td>住院患者抗菌药物治疗前微生物检验样本送检情况</td>
                      <td>{{ yaoLiXiaoJieList.microorganismSample }}</td>
                    </tr>
                    <tr align="center">
                      <td>住院患者基本药物使用金额占比（不包括中药饮片）</td>
                      <td>
                        {{ yaoLiXiaoJieList.baseMedicationAmountPercent }}
                      </td>
                    </tr>
                    <tr align="center">
                      <td>住院患者基本药物使用品种数情况（不包括中药饮片）</td>
                      <td>{{ yaoLiXiaoJieList.baseMedicationNumCondition }}</td>
                    </tr>
                    <tr align="center">
                      <td>住院患者集中带量采购品种使用金额占比</td>
                      <td>{{ yaoLiXiaoJieList.purchaseAmountPercent }}</td>
                    </tr>
                    <tr align="center">
                      <td>住院患者使用中药金额占比</td>
                      <td>
                        {{ yaoLiXiaoJieList.traditionalPillsAmountPercent }}
                      </td>
                    </tr>
                    <tr align="center">
                      <td>住院患者使用中药饮片金额占比</td>
                      <td>
                        {{ yaoLiXiaoJieList.traditionalDrinkAmountPercent }}
                      </td>
                    </tr>
                    <tr align="center">
                      <td>住院患者使用本院中药制剂金额占比</td>
                      <td>
                        {{ yaoLiXiaoJieList.traditionalThisAmountPercent }}
                      </td>
                    </tr>
                    <tr align="center">
                      <td style="border-bottom: none !important">
                        住院患者药品（不含中药饮片）使用金额占比情况
                      </td>
                      <td style="border-bottom: none !important">
                        {{ yaoLiXiaoJieList.pillsAmountPercent }}
                      </td>
                    </tr>
                  </table>
                </div>
              </td>
            </tr>
          </table>
        </div>
        <div style="float: right; margin-top: 20px">
          <el-button
            :loading="downAllyaoLiXiaoLoading"
            type="primary"
            @click="downAllyaoLiXiao"
          >下载完整药历
          </el-button
          >
        </div>
      </div>
    </div>

    <!-- 右侧折叠按钮 -->
    <el-tooltip
      class="item"
      effect="dark"
      :content="rightShow ? '隐藏右侧药历表格' : '显示右侧药历表格'"
      placement="bottom"
    >
      <div
        @click="showRightBox"
        class="fixed-element"
        :class="rightShow ? 'el-icon-arrow-right' : 'el-icon-arrow-left'"
        style="
          font-size: 18px;
          cursor: pointer;
          position: fixed;
          right: 0;
          top: 45%;
          box-shadow: 0 0 6px rgb(0 0 0 / 12%);
          border: 1px solid #ccc; /* 添加一个半透明黑色边框 */
          z-index: 5;
          color: #409eff;
          width: 30px;
          height: 30px;
          border-radius: 50%;
          display: flex;
          align-items: center;
          justify-content: center;
        "
      ></div>
    </el-tooltip>
    <!-- 添加或修改工作站模板信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-button
        style="float: right; margin-bottom: 10px; background-color: #1292b9"
        type="primary"
        icon="el-icon-plus"
        @click="handleAdd"
        v-hasPermi="['workstation:templateInfo:add']"
      >新增
      </el-button
      >
      <el-table
        v-loading="loading"
        :data="templateInfoList"
        key="templateInfoList"
        @selection-change="handleSelectionChange"
      >
        <el-table-column label="模板名称" align="center" prop="templateName"/>
        <el-table-column label="创建人" align="center" prop="createBy"/>
        <el-table-column label="创建时间" align="center" prop="createTime"/>
        <el-table-column
          label="操作"
          align="center"
          class-name="small-padding fixed-width"
        >
          <template slot-scope="scope">
            <el-button size="mini" type="text" @click="handleUpdate(scope.row)"
            >查看
            </el-button
            >
            <el-button
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="handleDelete(scope.row)"
            >删除
            </el-button
            >
          </template>
        </el-table-column>
      </el-table>

      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="params.pageNum"
        :limit.sync="params.pageSize"
        @pagination="getList"
      />
      <div slot="footer" class="dialog-footer">
        <el-button
          v-if="this.title !== '引用模板'"
          :loading="buttonLoading"
          type="primary"
          @click="useTemplate"
          style="background-color: #1292b9"
        >确 定
        </el-button
        >
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 新增模板信息对话框 -->
    <el-dialog
      :title="title"
      :visible.sync="open1"
      width="800px"
      append-to-body
    >
      <el-form
        ref="form"
        :model="templateList"
        :rules="rules"
        :disabled="disabled"
        label-width="90px"
      >
        <el-form-item label="模板名称：" prop="templateName">
          <el-input
            v-model="templateList.templateName"
            placeholder="请输入模板名称"
          />
        </el-form-item>
        <el-form-item label="模板内容：" prop="templateContent">
          <!-- <editor v-model="templateList.templateContent" :min-height="192" /> -->
          <el-input
            type="textarea"
            :rows="8"
            placeholder="请输入模板内容"
            v-model="templateList.templateContent"
          >
          </el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button
          type="primary"
          @click="enterUse(params.templateType)"
          v-if="this.title == '添加模板'"
          style="background-color: #1292b9"
        >确定并引用
        </el-button
        >
        <el-button
          :loading="buttonLoading"
          type="primary"
          @click="submitForm(params.templateType)"
          style="background-color: #1292b9"
        >确 定
        </el-button
        >
        <el-button @click="cancel1">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 添加或修改HIS系统医嘱对话框 -->
    <el-dialog
      title="HIS系统医嘱用药"
      :visible.sync="medicalOrdersOpen"
      width="1200px"
      append-to-body
    >
      <el-table
        v-if="
          medicalOrdersType == 5 ||
          medicalOrdersType == 6 ||
          medicalOrdersType == 8 ||
          medicalOrdersType == 10
        "
        :cell-class-name="isRender"
        ref="multipleTable3"
        @select="selectAllFun3"
        @select-all="selectAllFun3"
        @selection-change="selectionChangeHandle3"
        v-loading="tabloading"
        :data="medicalOrdersList3"
        style="width: 100%; margin-bottom: 20px"
        row-key="orderItemId"
        border
        :default-expand-all="false"
        :tree-props="{
          children: 'childMedicalRecordList',
          hasChildren: 'hasChildren',
        }"
      >
        <el-table-column type="selection" width="55" align="center"/>
        <el-table-column
          label="药物名称"
          align="center"
          width="280"
          prop="pillsName"
        />
        <el-table-column label="单次剂量" align="center" prop="amountPer"/>
        <el-table-column label="用法" align="center" prop="pillsUsage"/>
        <el-table-column label="频次" align="center" prop="frequency"/>
        <el-table-column label="起始日期" align="center" prop="beginDate">
          <template slot-scope="scope">
            <span>{{ scope.row.beginDate }}</span>
          </template>
        </el-table-column>
        <el-table-column label="结束日期" align="center" prop="endDate">
          <template slot-scope="scope">
            <span>{{ scope.row.endDate }}</span>
          </template>
        </el-table-column>
      </el-table>
      <el-tabs
        v-model="activeName"
        type="border-card"
        @tab-click="handleClick"
        v-else
      >
        <el-tab-pane label="长嘱" name="first">
          <el-table
            ref="multipleTable"
            :data="medicalOrdersList"
            row-key="orderItemId"
            border
            :cell-class-name="isRender"
            :default-expand-all="true"
            :tree-props="{
              children: 'childMedicalRecordList',
              hasChildren: 'hasChildren',
            }"
            v-loading="tabloading"
            @select="selectFun"
            @select-all="selectAllFun"
            @selection-change="selectionChangeHandle"
          >
            <el-table-column type="selection" width="55" align="center"/>
            <el-table-column
              label="药物名称"
              align="center"
              prop="pillsName"
              width="280"
            />
            <el-table-column label="单次剂量" align="center" prop="amountPer"/>
            <el-table-column label="用法" align="center" prop="pillsUsage"/>
            <el-table-column label="频次" align="center" prop="frequency"/>
            <el-table-column label="起始日期" align="center" prop="beginDate">
              <template slot-scope="scope">
                <span>{{ scope.row.beginDate }}</span>
              </template>
            </el-table-column>
            <el-table-column label="结束日期" align="center" prop="endDate">
              <template slot-scope="scope">
                <span>{{ scope.row.endDate }}</span>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane label="临嘱" name="second">
          <el-table
            :cell-class-name="isRender"
            ref="multipleTable2"
            @select="selectFun2"
            @select-all="selectAllFun2"
            @selection-change="selectionChangeHandle2"
            :data="medicalOrdersList2"
            style="width: 100%; margin-bottom: 20px"
            row-key="orderItemId"
            border
            v-loading="tabloading"
            :default-expand-all="true"
            :tree-props="{
              children: 'childMedicalRecordList',
              hasChildren: 'hasChildren',
            }"
          >
            <el-table-column type="selection" width="55" align="center"/>
            <el-table-column
              label="药物名称"
              align="center"
              width="280"
              prop="pillsName"
            />
            <el-table-column label="单次剂量" align="center" prop="amountPer"/>
            <el-table-column label="用法" align="center" prop="pillsUsage"/>
            <el-table-column label="频次" align="center" prop="frequency"/>
            <el-table-column label="起始日期" align="center" prop="beginDate">
              <template slot-scope="scope">
                <span>{{ scope.row.beginDate }}</span>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
      </el-tabs>

      <el-table
        v-if="false"
        :data="medicalOrdersList"
        @selection-change="handlemedicalOrdersList"
        border
      >
        <el-table-column type="selection" width="55" align="center"/>
        <el-table-column label="药物名称" align="center" prop="pillsName"/>
        <el-table-column label="单次剂量" align="center" prop="amountPer"/>
        <el-table-column label="用法" align="center" prop="pillsUsage"/>
        <el-table-column label="频次" align="center" prop="frequency"/>
        <el-table-column
          label="是否继续使用"
          align="center"
          prop="isContinue"
          width="100"
        />
        <el-table-column label="起始日期" align="center" prop="beginDate">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.beginDate, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="结束日期" align="center" prop="endDate">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.endDate, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button
          :loading="medicalOrdersButtonLoading"
          type="primary"
          v-loading="tabloading"
          @click="addYaoLI(medicalOrdersType)"
        >确 定
        </el-button
        >
        <el-button @click="medicalOrdersCancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { parseTime, getJetLag } from '@/utils/ruoyi.js'
import RuYuanPingGu from './components/ruYuanPingGu'
import YongYaoShiJianZhou from './components/yongyaoshijianzhou'
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import {
  listUser,
  getUser,
  delUser,
  addUser,
  updateUser,
  resetUserPwd,
  changeUserStatus,
  deptTreeSelect
} from '@/api/system/user'
import { getDicts } from '@/api/system/dict/data'
import {
  medicationRecordGet,
  medicalRecodeNo,
  medicationRecordPost,
  medicalOrders,
  medicalOrderscategory,
  medicineInfoList
} from '@/api/workstation/baseInfo'
import {
  listTemplateInfo,
  getTemplateInfo,
  delTemplateInfo,
  addTemplateInfo,
  updateTemplateInfo
} from '@/api/workstation/templateInfo//templateInfo.js'
import {
  listPharmaceuticalCare,
  getPharmaceuticalCare,
  delPharmaceuticalCare,
  addPharmaceuticalCare,
  updatePharmaceuticalCare,
  removePharmaceuticalCare
} from '@/api/workstation/pharmaceuticalCareDetail/pharmaceuticalCareDetail.js'
// 药历小结相关接口
import {
  listMedicationSummary,
  getMedicationSummary,
  delMedicationSummary,
  addMedicationSummary,
  updateMedicationSummary,
  medicalRecordList,
  statemedicalRecordNo
} from '@/api/workstation/medicationSummary/medicationSummary.js'
import { log } from 'console'

export default {
  name: 'medicineIndex',
  components: {
    RuYuanPingGu,
    YongYaoShiJianZhou,
    Treeselect
  },
  data() {
    return {
      medicalRecordNo: '', // 路由传过来的药历号
      dataloading: true,
      startDate: null,
      setDisabled: {
        // 返回禁用时间
        disabledDate(time) {
          const date = new Date(time)
          return time.getTime() > Date.now() // 可选历史天、可选当前天、不可选未来天
          // return time.getTime() > Date.now() - 8.64e7;  // 可选历史天、不可选当前天、不可选未来天
          // return time.getTime() < Date.now() - 8.64e7;  // 不可选历史天、可选当前天、可选未来天
          // return time.getTime() < Date.now(); // 不可选历史天、不可选当前天、可选未来天
        }
      },
      activeCard: ['1'],
      // 表单参数
      form: {
        patientBaseInfoVo: {
          admissionTime: ''
        },
        nowMedicalRecordVoList: [],
        beforeMedicalRecordVoList: [],
        initalMedicalRecordVoList: [],
        initTraditionalMedicalList: [],
        traditionalDiagnosisVoList: [],
        disposeAndResult: [],
        medicalGuardianSchedule:
          '(1)病情变化（注：从患者疾病的临床表现（症状、体征）的变化包括中医望闻问切诊内容，辅助检查结果，等指标情况确定有效性和安全性的监护时间和方法等。用药期间有无新发症状是否与药物存在相关性等安全性。)\n(2)合理用药情况（注：主要记录患者住院医嘱前置审核中需要医师双签的内容及个体化给药相关检测结果（如血药浓度监测和基因检测）并做简要分析评价。)\n(3)医保费用情况（注:统计患者药物治疗方案中各类药物的费用占比情况，包括药品使用金额占比和自费药品使用金额占比。)\n(4)其他药事管理指标（注：重点汇总分析每位患者治疗过程中的药物治疗方案是否满足医疗机构各项药事管理指标的要求。)'
      },
      // 表单校验
      rules: {
        id: [{ required: true, message: '患者ID不能为空', trigger: 'blur' }],
        patientName: [
          { required: true, message: '患者姓名不能为空', trigger: 'blur' }
        ],
        medicalRecordNo: [
          { required: true, message: '流水号不能为空', trigger: 'blur' }
        ],
        patientNo: [
          { required: true, message: 'ID号不能为空', trigger: 'blur' }
        ],
        deptId: [
          { required: true, message: '科室/病区不能为空', trigger: 'blur' }
        ],
        admissionDate: [
          { required: true, message: '入院时间不能为空', trigger: 'blur' }
        ],
        doctorId: [
          { required: true, message: '主管医生不能为空', trigger: 'blur' }
        ],
        bedNo: [{ required: true, message: '床号不能为空', trigger: 'blur' }],
        firstDiagnose: [
          { required: true, message: '第一诊断不能为空', trigger: 'blur' }
        ],
        guardianLevel: [
          { required: true, message: '监护分级不能为空', trigger: 'blur' }
        ],
        patientState: [
          { required: true, message: '住院状态不能为空', trigger: 'blur' }
        ],
        patientSex: [
          { required: true, message: '患者性别不能为空', trigger: 'blur' }
        ],
        patientAge: [
          { required: true, message: '年龄不能为空', trigger: 'blur' }
        ],
        patientProfession: [
          { required: true, message: '职业不能为空', trigger: 'blur' }
        ],
        nation: [{ required: true, message: '民族不能为空', trigger: 'blur' }],
        patientHeight: [
          { required: true, message: '身高不能为空', trigger: 'blur' }
        ],
        patientWeight: [
          { required: true, message: '体重不能为空', trigger: 'blur' }
        ],
        patientBmi: [
          { required: true, message: 'BMI不能为空', trigger: 'blur' }
        ],
        phoneNo: [
          { required: true, message: '联系方式不能为空', trigger: 'blur' }
        ],
        payWay: [{ required: true, message: '费别不能为空', trigger: 'blur' }],
        sourceInfo: [
          { required: true, message: '数据来源不能为空', trigger: 'blur' }
        ]
      },
      // 部门树选项
      deptOptions: [],
      // 按钮loading
      buttonLoading: false,
      guardianLevel: [], // 监护分级
      patientState: [], // 住院状态
      userSex: [], // 患者性别
      payWay: [], // 费别
      id: undefined, // 患者ID
      checkList: [], // 不良嗜好选中的数组
      disposeResult: [], // 过敏史处理措施及结果
      queryParams: [], // 药学评估结果
      MedicationRecordLoading: false, // 药历首页保存按钮加载状态
      downMedicationRecordLoading: false, // 药历首页下载按钮加载状态
      style: '', // 右侧表单样式 距离顶部距离
      year: '1',
      month: '2',

      // 工作站模板相关数据  开始 开始
      disabled: true, // 查看弹窗禁用
      loading: true, // 遮罩层
      title: '', // 弹出层标题
      open: false, // 是否显示弹出层
      open1: false, // 是否显示弹出层
      total: 0, // 总条数
      templateInfoList: [], // 工作站模板信息表格数据
      params: {
        pageNum: 1,
        pageSize: 10,
        templateName: undefined,
        templateContent: undefined,
        templateType: undefined
      }, // 查询参数
      // 工作站模板相关数据  结束 结束

      // 药学监护记录相关数据  开始 开始 开始
      pharmaceuticalCare: {
        pharmaceuticalCareDetailBoList: [],
        pharmaceuticalCareDetailVoList: [],
        outMedicalRecordList: [],
        educWestMedicalRecordList: [],
        educTraditionalMedicalRecordList: [],
        medicationSummaryOption1: true,
        medicationSummaryOption2: true
      },
      downpharmaceuticalCareDetailVoListLoading: false, // 下载出院用药教育按钮状态
      downpharmaceuticalCareLoading: false, // 下载药学监护计划按钮状态
      templateList: {}, // 模板数据
      dischargePharmacyEducation: '', // 出院用药教育
      // 药学监护记录相关数据  结束 结束

      // 药历小结信息数据  开始 开始
      yaoLiXiaoJieList: {
        traditionalDiagnosisBoList: [],
        traditionalDiagnosisVoList: [],
        medicalRecordBoList: [],
        medicalRecordVoList: [],
        summaryTraditionalMedicalRecordList: [],
        dischargePillsOption: false
      },
      downyaoLiXiaoJieListLoading: false, // 下载药学监护小结按钮状态
      // 药历小结信息数据  结束 结束

      nowTime: Date.parse(new Date()),
      downAllyaoLiXiaoLoading: false, // 下载全部药历按钮状态
      medicalOrdersList: [], // HIS系统中的医嘱数据
      medicalOrdersList2: [], // HIS系统中的医嘱数据
      medicalOrdersList3: [], // HIS系统中的医嘱数据
      medicalOrdersList4: [], // HIS系统中的医嘱数据 中转用
      medicalOrdersList5: [], // HIS系统中的医嘱数据 中转用
      medicalOrdersList6: [], // HIS系统中的医嘱数据 中转用
      medicalOrdersOpen: false, // HIS系统中的医嘱弹窗开关
      medicalOrdersButtonLoading: false, // HIS系统中的医嘱弹窗按钮状态
      medicalOrdersType: undefined, // 区分药历页还是药历小结点击确定
      medicalOrdersObj: [], // 勾选后保存当前行数据
      medicalOrdersObj1: [], // 勾选后保存当前行数据 长嘱
      medicalOrdersObj2: [], // 勾选后保存当前行数据 西药
      medicalOrdersObj3: [], // 勾选后保存当前行数据 中药饮片
      activeName: 'first', // 查询HIS医嘱 默认打开长嘱
      tabloading: false, // 查询HIS医嘱 loading 状态
      yaoxuejianhuindex: '', // 保存查询his长嘱临嘱药 往药学监护记录插入数据的index
      yaoxuejianhuzhongyaoindex: '', // 保存查询his中药 往药学监护记录插入数据的index
      rightShow: true, // 按钮控制 右侧是否显示
      errormsg1: ''
    }
  },
  created() {
    this.form.id = this.$route.query.id
    this.form.medicalRecordNo = this.$route.query.medicalRecordNo + ''
    this.medicalRecordNo = this.$route.query.medicalRecordNo + ''
    // 字典查询  过敏史处理措施及结果
    getDicts('dispose_and_result').then((res) => {
      this.disposeResult = res.data.filter((item) => {
        return item.dictLabel !== '其他'
      })
    })
    // 字典查询  监护分级
    getDicts('guardian_level').then((res) => {
      this.guardianLevel = res.data
    })
    // 字典查询  住院状态
    getDicts('patient_state').then((res) => {
      this.patientState = res.data
    })
    // 字典查询  患者性别
    getDicts('sys_user_sex').then((res) => {
      this.userSex = res.data
    })
    // 字典查询  费别
    getDicts('pay_way').then((res) => {
      this.payWay = res.data
    })
    // 先获取药历首页信息详细信息
    this.getYaoLiShouYeList()
    // 先获取药学监护记录详细信息
    // this.getYaoXueJianHuList();
    // 先获取药历小结详细信息
    // this.getYaoLiXiaoJieList();
    this.getDeptTree()
    // this.getBaseInfo();
  },
  mounted() {
    window.addEventListener('scroll', this.handleScroll) // 监听页面滚动
  },
  computed: {
    // 根据是否折叠左侧菜单  动态改变左侧盒子宽度
    leftBoxStyle() {
      // this.$store.state.app.sidebar.opened 等于 true 说明左侧菜单没有折叠
      // this.rightShow 等于 true 说明右侧表格 显示了
      // 总共有以下几种情况 1、左侧折叠 右侧不显示 2、左侧未折叠 右侧不显示 3、左侧折叠 右侧显示 4、左侧未折叠 右侧显示
      const isSidebarOpened = this.$store.state.app.sidebar.opened
      const isRightShown = this.rightShow
      let width = '53.5%'
      if (isSidebarOpened && isRightShown) {
        // 初始情况  两个都正常显示
        width = '53.5%'
      } else if (!isSidebarOpened && isRightShown) {
        // 左侧隐藏 右侧显示
        width = '57.5%'
      } else if (!isSidebarOpened && !isRightShown) {
        // 左侧隐藏 右侧不显示
        width = '99%'
      } else if (isSidebarOpened && !isRightShown) {
        // 左侧不隐藏 右侧不显示
        width = '99%'
      } else if (isSidebarOpened && isRightShown) {
        // 左侧不隐藏 右侧显示 这个其实就是初始情况
        width = '53.5%'
      }
      return { width }
    },
    // 动态计算费别
    feibie() {
      return (
        this.payWay.find(
          (user) => user.dictValue === this.form.patientBaseInfoVo.payWay
        ) || ''
      )
    },
    // 计算选择范围的起始日期和结束日期
    minDate() {
      const date = new Date(this.startDate)
      date.setDate(date.getDate() - 1) // 将日期往前推一天
      return date.getTime()
    },
    maxDate() {
      return new Date().getTime()
    },
    // 计算日期选择器的选项
    pickerOptions() {
      return {
        disabledDate: this.disabledDate,
        selectableRange: '00:00:00-00:00:00'
      }
    },
    // 登录人的名字
    user() {
      return this.$store.state.user.user.nickName
    }
  },
  // 滚动重置
  beforeDestroy() {
    window.removeEventListener('scroll', this.handleScroll)
  },
  methods: {
    // 提交并存档药历
    async sumbityaoLi() {
      const res = await statemedicalRecordNo(this.medicalRecordNo)
      if (res.code == 200) {
        // this.$message.msgSuccess(res.msg)
        this.$message({
          message: res.msg,
          type: 'success',
          showClose: true
        })
      }
    },
    // 处理行的上移逻辑
    moveUp(row, index, type, listindex) {
      if (type == 1) {
        // 药历页现病史汇总表格
        this.form.nowMedicalRecordVoList.splice(index, 1)
        this.form.nowMedicalRecordVoList.splice(index - 1, 0, row)
      } else if (type == 2) {
        // 药历页既往病史汇总表格
        this.form.beforeMedicalRecordVoList.splice(index, 1)
        this.form.beforeMedicalRecordVoList.splice(index - 1, 0, row)
      } else if (type == 3) {
        // 药历页初始病史 临嘱长嘱汇总表格
        this.form.initalMedicalRecordVoList.splice(index, 1)
        this.form.initalMedicalRecordVoList.splice(index - 1, 0, row)
      } else if (type == 4) {
        // 药历页初始病史 中药饮片汇总表格
        this.form.initTraditionalMedicalList.splice(index, 1)
        this.form.initTraditionalMedicalList.splice(index - 1, 0, row)
      } else if (type == 5) {
        // 药学监护页初始病史 临嘱长嘱汇总表格
        console.log(
          this.pharmaceuticalCare.pharmaceuticalCareDetailVoList[listindex]
            .careDetailMedicalList
        )
        console.log(row, listindex)
        this.pharmaceuticalCare.pharmaceuticalCareDetailVoList[
          listindex
          ].careDetailMedicalList.splice(index, 1)
        this.pharmaceuticalCare.pharmaceuticalCareDetailVoList[
          listindex
          ].careDetailMedicalList.splice(index - 1, 0, row)
      } else if (type == 6) {
        // 药学监护页初始病史 中药饮片汇总表格
        this.pharmaceuticalCare.pharmaceuticalCareDetailVoList[
          listindex
          ].traditionalMedicalList.splice(index, 1)
        this.pharmaceuticalCare.pharmaceuticalCareDetailVoList[
          listindex
          ].traditionalMedicalList.splice(index - 1, 0, row)
      } else if (type == 7) {
        // 药历页初始病史 出院用药  西药表格
        this.pharmaceuticalCare.educWestMedicalRecordList.splice(index, 1)
        this.pharmaceuticalCare.educWestMedicalRecordList.splice(
          index - 1,
          0,
          row
        )
      } else if (type == 8) {
        // 药历页初始病史 出院用药  中药表格
        this.pharmaceuticalCare.educTraditionalMedicalRecordList.splice(
          index,
          1
        )
        this.pharmaceuticalCare.educTraditionalMedicalRecordList.splice(
          index - 1,
          0,
          row
        )
      } else if (type == 9) {
        // 药历小结 住院用药  西药表格
        this.yaoLiXiaoJieList.medicalRecordVoList.splice(index, 1)
        this.yaoLiXiaoJieList.medicalRecordVoList.splice(index - 1, 0, row)
      } else if (type == 10) {
        // 药历小结 住院用药  中药表格
        this.yaoLiXiaoJieList.summaryTraditionalMedicalRecordList.splice(
          index,
          1
        )
        this.yaoLiXiaoJieList.summaryTraditionalMedicalRecordList.splice(
          index - 1,
          0,
          row
        )
      }
    },
    // 处理行的下移逻辑
    moveDown(row, index, type, listindex) {
      if (type == 1) {
        // 药历页现病史汇总表格
        this.form.nowMedicalRecordVoList.splice(index, 1)
        this.form.nowMedicalRecordVoList.splice(index + 1, 0, row)
      } else if (type == 2) {
        // 药历页既往病史汇总表格
        this.form.beforeMedicalRecordVoList.splice(index, 1)
        this.form.beforeMedicalRecordVoList.splice(index + 1, 0, row)
      } else if (type == 3) {
        // 药历页初始病史汇总表格
        this.form.initalMedicalRecordVoList.splice(index, 1)
        this.form.initalMedicalRecordVoList.splice(index + 1, 0, row)
      } else if (type == 4) {
        // 药历页初始病史 中药汇总表格
        this.form.initTraditionalMedicalList.splice(index, 1)
        this.form.initTraditionalMedicalList.splice(index + 1, 0, row)
      } else if (type == 5) {
        // 药学监护页  西药表格
        console.log(
          this.pharmaceuticalCare.pharmaceuticalCareDetailVoList[listindex]
            .careDetailMedicalList
        )
        console.log(row, listindex)
        this.pharmaceuticalCare.pharmaceuticalCareDetailVoList[
          listindex
          ].careDetailMedicalList.splice(index, 1)
        this.pharmaceuticalCare.pharmaceuticalCareDetailVoList[
          listindex
          ].careDetailMedicalList.splice(index + 1, 0, row)
      } else if (type == 6) {
        // 药学监护页  中药表格
        this.pharmaceuticalCare.pharmaceuticalCareDetailVoList[
          listindex
          ].traditionalMedicalList.splice(index, 1)
        this.pharmaceuticalCare.pharmaceuticalCareDetailVoList[
          listindex
          ].traditionalMedicalList.splice(index + 1, 0, row)
      } else if (type == 7) {
        // 药学监护页  出院用药 西药
        this.pharmaceuticalCare.educWestMedicalRecordList.splice(index, 1)
        this.pharmaceuticalCare.educWestMedicalRecordList.splice(
          index + 1,
          0,
          row
        )
      } else if (type == 8) {
        // 药学监护页  出院用药 中药
        this.pharmaceuticalCare.educTraditionalMedicalRecordList.splice(
          index,
          1
        )
        this.pharmaceuticalCare.educTraditionalMedicalRecordList.splice(
          index + 1,
          0,
          row
        )
      } else if (type == 9) {
        // 药历小结 住院用药  西药表格
        this.yaoLiXiaoJieList.medicalRecordVoList.splice(index, 1)
        this.yaoLiXiaoJieList.medicalRecordVoList.splice(index + 1, 0, row)
      } else if (type == 10) {
        // 药历小结 住院用药  中药表格
        this.yaoLiXiaoJieList.summaryTraditionalMedicalRecordList.splice(
          index,
          1
        )
        this.yaoLiXiaoJieList.summaryTraditionalMedicalRecordList.splice(
          index + 1,
          0,
          row
        )
      }
    },
    input1(val) {
      if (!val) {
        this.errormsg1 = ''
        return
      }
      const value = val.trim() // 获取输入框的值，并去除空格
      let reg = /^(0|[1-9]\d?|1[01]\d|120)$/
      if (!reg.test(value)) {
        // 如果输入的值不符合要求，则清空输入框
        this.errormsg1 = '请输入0-120的整数'
        this.form.patientBaseInfoVo.patientAge = ''
      } else {
        this.errormsg1 = ''
      }
    },
    input2(val) {
      if (!val) {
        return
      }
      const value = val.trim() // 获取输入框的值，并去除空格
      let reg = /^(0|[1-9]\d?|1[01]\d|12)$/
      if (!reg.test(value)) {
        // 如果输入的值不符合要求，则清空输入框
        this.errormsg1 = '请输入0-12的整数'
        this.form.patientBaseInfoVo.patientMonth = ''
      } else {
        this.errormsg1 = ''
      }
    },
    // 按钮控制右侧表格显示
    showRightBox() {
      this.rightShow = !this.rightShow
    },
    // 根据输入名字查询药品
    querySearchAsync(queryString, cb) {
      try {
        let results = []
        if (!queryString) {
          cb(results)
        } else {
          // 接口需要的参数
          let queryParams = {
            searchValue: queryString,
            pageSize: 30,
            pageNum: 1
          }
          //这里去查询后端的接口.根据自己接口的情况进行赋值
          medicineInfoList(queryParams).then((res) => {
            if (res.code == 200) {
              let resArr = res.rows
              //循环放到一个远程搜索需要的数组
              resArr.forEach((item) => {
                results.push({
                  value: item.medicineName,
                  id: item.id,
                  medicineSpell: item.medicineSpell
                })
              })
              cb(results)
            } else {
              results = []
              cb(results)
            }
          })
        }
      } catch (error) {
        console.log(error)
      }
    },
    //点击出现搜索后点击的每一项
    handleSelect(item) {
    },
    // 禁用指定日期之外的日期
    disabledDate(date) {
      return date.getTime() < this.minDate || date.getTime() > this.maxDate
    },
    // 年龄查看年和月
    ChangeYear(data) {
      console.log('[ data ] >', data)
    },
    // 计算bmi指数
    handleBmi() {
      if (
        !this.form.patientBaseInfoVo.patientWeight ||
        !this.form.patientBaseInfoVo.patientHeight
      ) {
        return
      }
      this.form.patientBaseInfoVo.patientBmi =
        this.form.patientBaseInfoVo.patientWeight /
        ((this.form.patientBaseInfoVo.patientHeight / 100) *
          (this.form.patientBaseInfoVo.patientHeight / 100))
      console.log(this.form.patientBaseInfoVo.patientBmi)
      this.form.patientBaseInfoVo.patientBmi =
        String(this.form.patientBaseInfoVo.patientBmi).slice(0, 5) ||
        this.form.patientBaseInfoVo.patientBmi.toFixed(2) // 保留两位小数
    },
    // 下载完整药历
    downAllyaoLiXiao() {
      if (!this.form.id) {
        this.$message({
          message: '请先填写药历首页信息,保存后再试！',
          type: 'warning',
          showClose: true
        })
        return
      }
      this.downAllyaoLiXiaoLoading = true
      this.$download.get(
        '/workstation/medicationRecord/overall/',
        this.medicalRecordNo,
        `${this.form.patientBaseInfoVo.patientName}完整药历.docx`
      )
      this.downAllyaoLiXiaoLoading = false
    },
    // 获取页面滚动距离 处理右侧表格
    handleScroll() {
      if (!this.activeCard) {
        return
      }
      if (this.activeCard.includes('2')) {
        let scrollTop =
          window.pageYOffset ||
          document.documentElement.scrollTop ||
          document.body.scrollTop
        // console.log(scrollTop, '滚动距离')
        this.$refs.rightBox.style.top = scrollTop * 0.36 - 87.6 + 'px'
      } else if (this.activeCard.includes('4')) {
        let scrollTop =
          window.pageYOffset ||
          document.documentElement.scrollTop ||
          document.body.scrollTop
        // console.log(scrollTop, '滚动距离')
        this.$refs.rightBox.style.top = scrollTop * 0.29 + 'px'
      }
    },
    // 药历首页 开始 开始
    // 获取药历首页信息详细信息
    getYaoLiShouYeList() {
      medicationRecordGet(this.medicalRecordNo)
        .then((res) => {
          if (res.data !== null) {
            // 请求药历页中药饮片 表格数据
            medicalRecordList({
              medicalRecordNo: this.medicalRecordNo,
              medicalType: '5'
            }).then((result) => {
              if (result.rows !== null) {
                this.form.initTraditionalMedicalList = result.rows
              }
            })
            res.data.patientBaseInfoVo = res.data.patientBaseInfoVo
              ? res.data.patientBaseInfoVo
              : {}
            res.data.patientBaseInfoVo.patientProfession = res.data
              .patientBaseInfoVo.patientProfession
              ? res.data.patientBaseInfoVo.patientProfession
              : '无'
            this.startDate = parseTime(
              res.data.patientBaseInfoVo.admissionTime,
              '{y}-{m}-{d}'
            )
            res.data.nowMedicalRecordVoList = res.data.nowMedicalRecordVoList
              ? ((res.data.medicationSummaryOption1 = true),
                res.data.nowMedicalRecordVoList)
              : ((res.data.medicationSummaryOption1 = false), [])

            res.data.beforeMedicalRecordVoList = res.data
              .beforeMedicalRecordVoList
              ? ((res.data.medicationSummaryOption2 = true),
                res.data.beforeMedicalRecordVoList)
              : ((res.data.medicationSummaryOption2 = false), [])
            res.data.initalMedicalRecordVoList = res.data
              .initalMedicalRecordVoList
              ? res.data.initalMedicalRecordVoList
              : []
            res.data.traditionalDiagnosisVoList = res.data
              .traditionalDiagnosisVoList
              ? res.data.traditionalDiagnosisVoList
              : []
            res.data.disposeAndResult = res.data.disposeAndResult
              ? [...res.data.disposeAndResult]
              : []
            // 药学监护计划默认可编辑模板
            if (!res.data.medicalGuardianSchedule) {
              res.data.medicalGuardianSchedule =
                '(1)病情变化（注：从患者疾病的临床表现（症状、体征）的变化包括中医望闻问切诊内容，辅助检查结果，等指标情况确定有效性和安全性的监护时间和方法等。用药期间有无新发症状是否与药物存在相关性等安全性。)\n(2)合理用药情况（注：主要记录患者住院医嘱前置审核中需要医师双签的内容及个体化给药相关检测结果（如血药浓度监测和基因检测）并做简要分析评价。)\n(3)医保费用情况（注:统计患者药物治疗方案中各类药物的费用占比情况，包括药品使用金额占比和自费药品使用金额占比。)\n(4)其他药事管理指标（注：重点汇总分析每位患者治疗过程中的药物治疗方案是否满足医疗机构各项药事管理指标的要求。)'
            }
            console.log('9999999999', res.data)
            this.form = res.data
            this.dataloading = false
          }
        })
        .finally(() => {
          this.dataloading = false
        })

      //  先获取是否评估过
      medicalRecodeNo(this.medicalRecordNo).then((res) => {
        if (res.data !== null) {
          this.queryParams = res.data
          console.log(this.queryParams)
        }
      })
    },
    // 保存药历首页结果
    submitMedicationRecord() {
      this.MedicationRecordLoading = true
      this.form.signer = this.user
      this.form.medicalRecordNo = this.medicalRecordNo + ''
      this.form.disposeAndResult = this.form.disposeAndResult.length
        ? this.form.disposeAndResult.join()
        : ''
      this.form.patientBaseInfoBo = this.form.patientBaseInfoVo
      delete this.form.patientBaseInfoVo
      // 根据选择框 点击有无 判断
      if (this.form.medicationSummaryOption1) {
        this.form.nowMedicalRecordVoList.forEach((item) => delete item.id)
      } else {
        this.form.nowMedicalRecordVoList = []
      }
      this.form.nowMedicalRecordList = this.form.nowMedicalRecordVoList
      delete this.form.nowMedicalRecordVoList
      // 根据选择框 点击有无 判断
      if (this.form.medicationSummaryOption2) {
        this.form.beforeMedicalRecordVoList.forEach((item) => delete item.id)
      } else {
        this.form.beforeMedicalRecordVoList = []
      }
      this.form.beforeMedicalRecordList = this.form.beforeMedicalRecordVoList
      delete this.form.beforeMedicalRecordVoList
      // 删除HIS西药 为了比对 添加的id  不删除保存失败
      if (
        this.form.initalMedicalRecordVoList &&
        this.form.initalMedicalRecordVoList.length > 0
      ) {
        this.form.initalMedicalRecordVoList.forEach((item) => delete item.id)
      }
      this.form.initalMedicalRecordList = this.form.initalMedicalRecordVoList
      delete this.form.initalMedicalRecordVoList
      this.form.traditionalDiagnosisList = this.form.traditionalDiagnosisVoList
      delete this.form.traditionalDiagnosisVoList
      // 删除HIS中药饮片 为了比对 添加的id  不删除保存失败
      if (
        this.form.initTraditionalMedicalList &&
        this.form.initTraditionalMedicalList.length > 0
      ) {
        this.form.initTraditionalMedicalList.forEach((item) => {
          delete item.id
        })
      }
      medicationRecordPost(this.form)
        .then((res) => {
          if (res.code === 200) {
            this.$message({
              type: 'success',
              message: res.msg
            })
            this.getYaoLiShouYeList()
            this.getDeptTree()
            this.MedicationRecordLoading = false
          } else {
            this.$message({
              type: 'error',
              message: res.msg
            })
            this.MedicationRecordLoading = false
          }
        })
        .finally(() => {
          this.MedicationRecordLoading = false
        })
    },
    // 不良嗜好 选中状态
    handleisHaveBadHobby(val) {
      // 等于0 说明没有不良嗜好
      if (val == 0) {
        this.$set(this.form, 'isHaveBadHobby', val)
        this.$set(this.form, 'isWine', '0')
        this.$set(this.form, 'wineYear', '')
        this.$set(this.form, 'wineAmountPerDay', '')
        this.$set(this.form, 'isSmoke', '0')
        this.$set(this.form, 'smokeYear', '')
        this.$set(this.form, 'smokeAmountPerDay', '')
        this.$set(this.form, 'isEat', '0')
        this.$set(this.form, 'eatBadHobby', '')
        this.$set(this.form, 'isOther', '0')
        this.$set(this.form, 'otherBadHobby', '')
      }
    },
    // 喝酒
    handleisWine(val) {
      console.log(val)
      if (val == 1) {
        //  说明被选中了 此时需要取消
        this.$set(this.form, 'isWine', '0')
        this.$set(this.form, 'wineYear', '')
        this.$set(this.form, 'wineAmountPerDay', '')
      } else {
        this.form.isWine = '1'
      }
    },
    // 吸烟
    handleisSmoke(val) {
      if (val == 1) {
        //  说明被选中了 此时需要取消
        this.$set(this.form, 'isSmoke', '0')
        this.$set(this.form, 'smokeYear', '')
        this.$set(this.form, 'smokeAmountPerDay', '')
      } else {
        this.form.isSmoke = '1'
      }
    },
    // 饮食
    handleisEat(val) {
      if (val == 1) {
        //  说明被选中了 此时需要取消
        this.$set(this.form, 'isEat', '0')
        this.$set(this.form, 'eatBadHobby', '')
      } else {
        this.form.isEat = '1'
      }
    },
    // 其他
    handleisOther(val) {
      if (val == 1) {
        //  说明被选中了 此时需要取消
        this.$set(this.form, 'isOther', '0')
        this.$set(this.form, 'otherBadHobby', '')
      } else {
        this.form.isOther = '1'
      }
    },
    // 是否有过敏史选择框
    handleisHaveAllergy(val) {
      // 等于0 说明没有过敏史
      if (val == 0) {
        this.$set(this.form, 'isHaveAllergy', val)
        this.$set(this.form, 'doubtPillsOrFoodName', '')
        this.$set(this.form, 'adrClinicFeature', '')
        this.$set(this.form, 'disposeAndResult', '')
        this.$set(this.form, 'isOtherDisposeAndResult', '')
        this.$set(this.form, 'otherDisposeAndResult', '')
      }
    },
    // 过敏史 中其他选择框
    handleisOtherDisposeAndResult(val) {
      if (val == 1) {
        //  说明被选中了 此时需要取消
        this.$set(this.form, 'isOtherDisposeAndResult', '0')
        this.$set(this.form, 'otherDisposeAndResult', '')
      } else {
        this.form.isOtherDisposeAndResult = '1'
      }
    },
    // 现病史用药汇总增加一行
    addNowMedicalRecordList() {
      let obj = {
        purpose: '',
        pillsName: '',
        amount: '',
        pillsCycle: '',
        isContinue: '',
        medicalType: '0',
        medicalRecordNo: this.medicalRecordNo
      }
      this.form.nowMedicalRecordVoList.push(obj)
    },
    // 现病史用药汇总 删除一行
    delNowMedicalRecordVoList(row, index) {
      this.form.nowMedicalRecordVoList.splice(index, 1)
    },
    // 既往病史用药汇总增加一行
    addbeforeMedicalRecordList() {
      let obj = {
        amount: '',
        pillsCycle: '',
        purpose: '',
        pillsName: '',
        isContinue: '',
        medicalType: '1',
        medicalRecordNo: this.medicalRecordNo
      }
      this.form.beforeMedicalRecordVoList.push(obj)
      console.log(this.form.beforeMedicalRecordVoList)
    },
    // 既往病史用药汇总 删除一行
    delBeforeMedicalRecordVoList(row, index) {
      this.form.beforeMedicalRecordVoList.splice(index, 1)
    },
    // 查询HIS医嘱
    async getHISdirLog(type, index) {
      this.medicalOrdersType = type
      this.tabloading = true
      this.medicalOrdersOpen = true
      // 增加分组后的新接口
      try {
        // 1、比对已经有的药 和HIS中 重复的不显示
        if (type == 2) {
          const res1 = await medicalOrderscategory(this.medicalRecordNo, 1)
          const res2 = await medicalOrderscategory(this.medicalRecordNo, 2)
          this.medicalOrdersList4 = res1.data || []
          this.medicalOrdersList5 = res2.data || []
          // 药历首页  初始用药 药历首页初始用药比对
          if (
            this.form.initalMedicalRecordVoList &&
            this.form.initalMedicalRecordVoList.length > 0
          ) {
            [this.medicalOrdersList4, this.medicalOrdersList5] = [
              this.medicalOrdersList4,
              this.medicalOrdersList5
            ].map((array) =>
              array.filter(
                (item) =>
                  !this.form.initalMedicalRecordVoList.some(
                    (obj) => obj.id === item.id
                  )
              )
            )
            this.medicalOrdersList = this.medicalOrdersList4
            this.medicalOrdersList2 = this.medicalOrdersList5
            this.tabloading = false
          } else {
            this.medicalOrdersList = this.medicalOrdersList4
            this.medicalOrdersList2 = this.medicalOrdersList5
            this.tabloading = false
          }
        } else if (type == 3) {
          // 药历小结  住院期间治疗药物汇总   药历小结中  住院期间治疗药物汇总比对代码
          const res1 = await medicalOrderscategory(this.medicalRecordNo, 1)
          const res2 = await medicalOrderscategory(this.medicalRecordNo, 2)
          this.medicalOrdersList4 = res1.data || []
          this.medicalOrdersList5 = res2.data || []
          if (
            this.yaoLiXiaoJieList.medicalRecordVoList &&
            this.yaoLiXiaoJieList.medicalRecordVoList.length > 0
          ) {
            [this.medicalOrdersList4, this.medicalOrdersList5] = [
              this.medicalOrdersList4,
              this.medicalOrdersList5
            ].map((array) =>
              array.filter(
                (item) =>
                  !this.yaoLiXiaoJieList.medicalRecordVoList.some(
                    (obj) => obj.id === item.id
                  )
              )
            )
            this.medicalOrdersList = this.medicalOrdersList4
            this.medicalOrdersList2 = this.medicalOrdersList5
            this.tabloading = false
          } else {
            this.medicalOrdersList = this.medicalOrdersList4
            this.medicalOrdersList2 = this.medicalOrdersList5
            this.tabloading = false
          }
        } else if (type == 5) {
          // 说明此时打开的只是药历页面中药饮片
          const res3 = await medicalOrderscategory(this.medicalRecordNo, 3)
          this.medicalOrdersList6 = res3.data || []
          // 比对用药是否有重复的
          if (
            this.form.initTraditionalMedicalList &&
            this.form.initTraditionalMedicalList.length > 0
          ) {
            [this.medicalOrdersList6] = [this.medicalOrdersList6].map((array) =>
              array.filter(
                (item) =>
                  !this.form.initTraditionalMedicalList.some(
                    (obj) => obj.id === item.id
                  )
              )
            )
            console.log(this.medicalOrdersList6)
            this.medicalOrdersList3 = this.medicalOrdersList6 || []
            this.tabloading = false
          } else {
            this.medicalOrdersList3 = this.medicalOrdersList6 || []
            this.tabloading = false
          }
        } else if (type == 6) {
          // 说明此时打开的药历小结页面中药饮片
          const res3 = await medicalOrderscategory(this.medicalRecordNo, 3)
          this.medicalOrdersList6 = res3.data || []
          // 比对用药是否有重复的
          if (
            this.yaoLiXiaoJieList.summaryTraditionalMedicalRecordList &&
            this.yaoLiXiaoJieList.summaryTraditionalMedicalRecordList.length > 0
          ) {
            [this.medicalOrdersList6] = [this.medicalOrdersList6].map((array) =>
              array.filter(
                (item) =>
                  !this.yaoLiXiaoJieList.summaryTraditionalMedicalRecordList.some(
                    (obj) => obj.id === item.id
                  )
              )
            )
            this.medicalOrdersList3 = this.medicalOrdersList6 || []
            this.tabloading = false
          } else {
            this.medicalOrdersList3 = this.medicalOrdersList6 || []
            this.tabloading = false
          }
        } else if (type == 7) {
          // 说明此时打开的药学监护记录页面  查询中西嘱
          this.yaoxuejianhuindex = index
          const res1 = await medicalOrderscategory(this.medicalRecordNo, 1)
          const res2 = await medicalOrderscategory(this.medicalRecordNo, 2)
          this.medicalOrdersList4 = res1.data || []
          this.medicalOrdersList5 = res2.data || []
          // 药历首页  初始用药 药历首页初始用药比对
          if (
            this.pharmaceuticalCare.pharmaceuticalCareDetailVoList[index]
              .careDetailMedicalList &&
            this.pharmaceuticalCare.pharmaceuticalCareDetailVoList[index]
              .careDetailMedicalList.length > 0
          ) {
            [this.medicalOrdersList4, this.medicalOrdersList5] = [
              this.medicalOrdersList4,
              this.medicalOrdersList5
            ].map((array) =>
              array.filter(
                (item) =>
                  !this.pharmaceuticalCare.pharmaceuticalCareDetailVoList[
                    index
                    ].careDetailMedicalList.some((obj) => obj.id === item.id)
              )
            )
            this.medicalOrdersList = this.medicalOrdersList4
            this.medicalOrdersList2 = this.medicalOrdersList5
            this.tabloading = false
          } else {
            this.medicalOrdersList = this.medicalOrdersList4
            this.medicalOrdersList2 = this.medicalOrdersList5
            this.tabloading = false
          }
        } else if (type == 8) {
          this.yaoxuejianhuzhongyaoindex = index
          // 说明此时打开的药学监护记录页面中药饮片
          const res3 = await medicalOrderscategory(this.medicalRecordNo, 3)
          this.medicalOrdersList6 = res3.data || []
          // 比对用药是否有重复的
          if (
            this.pharmaceuticalCare.pharmaceuticalCareDetailVoList[index]
              .traditionalMedicalList &&
            this.pharmaceuticalCare.pharmaceuticalCareDetailVoList[index]
              .traditionalMedicalList.length > 0
          ) {
            [this.medicalOrdersList6] = [this.medicalOrdersList6].map((array) =>
              array.filter(
                (item) =>
                  !this.pharmaceuticalCare.pharmaceuticalCareDetailVoList[
                    index
                    ].traditionalMedicalList.some((obj) => obj.id === item.id)
              )
            )
            this.medicalOrdersList3 = this.medicalOrdersList6 || []
            this.tabloading = false
          } else {
            this.medicalOrdersList3 = this.medicalOrdersList6 || []
            this.tabloading = false
          }
        } else if (type == 9) {
          // 此时打开的时药学监护记录的  出院用药的西药
          const res1 = await medicalOrderscategory(this.medicalRecordNo, 1)
          const res2 = await medicalOrderscategory(this.medicalRecordNo, 2)
          this.medicalOrdersList4 = res1.data || []
          this.medicalOrdersList5 = res2.data || []
          // 药学监护记录的  出院用药的西药
          if (
            this.pharmaceuticalCare.educWestMedicalRecordList &&
            this.pharmaceuticalCare.educWestMedicalRecordList.length > 0
          ) {
            [this.medicalOrdersList4, this.medicalOrdersList5] = [
              this.medicalOrdersList4,
              this.medicalOrdersList5
            ].map((array) =>
              array.filter(
                (item) =>
                  !this.pharmaceuticalCare.educWestMedicalRecordList.some(
                    (obj) => obj.id === item.id
                  )
              )
            )
            this.medicalOrdersList = this.medicalOrdersList4
            this.medicalOrdersList2 = this.medicalOrdersList5
            this.tabloading = false
          } else {
            this.medicalOrdersList = this.medicalOrdersList4
            this.medicalOrdersList2 = this.medicalOrdersList5
            this.tabloading = false
          }
        } else if (type == 10) {
          // 说明此时打开的药学监护记录 出院用药中药饮片
          const res3 = await medicalOrderscategory(this.medicalRecordNo, 3)
          this.medicalOrdersList6 = res3.data || []
          // 比对用药是否有重复的
          if (
            this.pharmaceuticalCare.educTraditionalMedicalRecordList &&
            this.pharmaceuticalCare.educTraditionalMedicalRecordList.length > 0
          ) {
            [this.medicalOrdersList6] = [this.medicalOrdersList6].map((array) =>
              array.filter(
                (item) =>
                  !this.pharmaceuticalCare.educTraditionalMedicalRecordList.some(
                    (obj) => obj.id === item.id
                  )
              )
            )
            this.medicalOrdersList3 = this.medicalOrdersList6 || []
            this.tabloading = false
          } else {
            this.medicalOrdersList3 = this.medicalOrdersList6 || []
            this.tabloading = false
          }
        }
      } catch (error) {
        console.log(error)
      } finally {
        this.tabloading = false
      }
    },
    // 懒加载
    changeload(tree, treeNode, resolve) {
    },
    // 查询HIS医嘱 切换tab
    handleClick(tab, event) {
    },
    // 判断子集的选择框是否显示
    isRender(row) {
      if (row.row.childMedicalRecordList == null) {
        return 'disabled-column'
      }
    },
    // 选择长嘱 处理选择父节点后 同时勾选子节点
    selectFun(selection, row) {
    },
    selectAllFun(selection) {
    },
    selectionChangeHandle(selection) {
      this.medicalOrdersObj1 = selection
    },
    // 选择西药 处理选择父节点后 同时勾选子节点
    // 单个选择
    selectFun2(selection, row) {
    },
    // 点击全选 取消全选
    selectAllFun2(selection) {
    },
    // 当选择项发生变化时
    selectionChangeHandle2(selection) {
      this.medicalOrdersObj2 = selection
    },
    // 选择中药饮片 处理选择父节点后 同时勾选子节点
    selectFun3(selection, row) {
    },
    selectAllFun3(selection) {
    },
    selectionChangeHandle3(selection) {
      console.log(selection)
      this.medicalOrdersObj3 = selection
    },
    // 多选后选择
    handlemedicalOrdersList(selection) {
      console.log(selection)
      this.medicalOrdersObj = selection
    },
    // 查询HIS医嘱 确定按钮
    addYaoLI(type) {
      if (type == 2 || type == 3 || type == 7 || type == 9) {
        if (
          this.medicalOrdersObj1.length == 0 &&
          this.medicalOrdersObj2.length == 0
        ) {
          this.medicalOrdersOpen = false
          return
        }
      } else if (type == 5 || type == 6 || type == 8 || type == 10) {
        if (this.medicalOrdersObj3.length == 0) {
          this.medicalOrdersOpen = false
          return
        }
      }
      // 表示药历页点击了查询his医嘱按钮
      if (type == 2) {
        this.medicalOrdersObj = [
          ...this.medicalOrdersObj1,
          ...this.medicalOrdersObj2
        ]
        let arr = []
        this.medicalOrdersObj.forEach((item) => {
          arr.push(item)
          if (
            item.childMedicalRecordList &&
            item.childMedicalRecordList.length
          ) {
            item.childMedicalRecordList.forEach((val) => {
              arr.push(val)
            })
          }
        })

        arr.forEach((item) => {
          item.medicalRecordNo = this.medicalRecordNo
          item.medicalType = '2'
          // this.form.XIYAO.push(item);
          this.form.initalMedicalRecordVoList.push(item)
        })
        this.medicalOrdersOpen = false
      } else if (type == 3) {
        // 表示药历小结页点击了确定
        this.medicalOrdersObj = [
          ...this.medicalOrdersObj1,
          ...this.medicalOrdersObj2
        ]
        let arr = []
        this.medicalOrdersObj.forEach((item) => {
          arr.push(item)
          if (
            item.childMedicalRecordList &&
            item.childMedicalRecordList.length
          ) {
            item.childMedicalRecordList.forEach((val) => {
              arr.push(val)
            })
          }
        })
        console.log(arr)
        console.log(this.medicalOrdersObj)
        // 表示药历小结中住院期间治疗药物汇总点击了查询his医嘱按钮
        arr.forEach((item) => {
          item.medicalRecordNo = this.medicalRecordNo
          item.medicalType = '3'
          this.yaoLiXiaoJieList.medicalRecordVoList.push(item)
        })
        this.medicalOrdersOpen = false
      } else if (type == 5) {
        // 表示药历页点击了中药饮片确定按钮
        this.medicalOrdersObj = [...this.medicalOrdersObj3]
        let arr = []
        this.medicalOrdersObj.forEach((item, index) => {
          item.medicalType = '5'
          item.medicalRecordNo = this.medicalRecordNo
          arr[index] = [item]
          if (
            item.childMedicalRecordList &&
            item.childMedicalRecordList.length
          ) {
            item.childMedicalRecordList.forEach((val) => {
              val.medicalType = '5'
              val.medicalRecordNo = this.medicalRecordNo
              val.id = item.id
              arr[index].push(val)
            })
          }
        })

        arr.forEach((item) => {
          let obj1 = {
            purpose: '',
            pillsName: '',
            pillsUsage: '',
            beginDate: '',
            endDate: '',
            medicalRecordNo: this.medicalRecordNo,
            medicalType: '5',
            id: ''
          }
          let count = 0 // 定义计数器
          item.forEach((val, index) => {
            obj1.purpose = val.purpose
            obj1.pillsUsage =
              String(val.pillsUsage) + ' ' + String(val.frequency)
            obj1.beginDate = val.beginDate
            obj1.endDate = val.endDate
            obj1.id = val.id // 为了一会比对删除 重复项

            if (count !== 0 && count % 4 === 0) {
              obj1.pillsName += '\n' // 每遍历4个元素，在当前元素后添加换行符
            }

            obj1.pillsName +=
              String(val.pillsName) + ' ' + String(val.amountPer) + ' '

            count++ // 每遍历一个元素计数器自增1
          })
          this.form.initTraditionalMedicalList.push(obj1)
        })
        this.medicalOrdersOpen = false
      } else if (type == 6) {
        // 表示药历小结页点击了中药饮片确定按钮
        this.medicalOrdersObj = [...this.medicalOrdersObj3]
        let arr = []
        this.medicalOrdersObj.forEach((item, index) => {
          item.medicalType = '6'
          item.medicalRecordNo = this.medicalRecordNo
          arr[index] = [item]
          if (
            item.childMedicalRecordList &&
            item.childMedicalRecordList.length
          ) {
            item.childMedicalRecordList.forEach((val) => {
              val.medicalType = '6'
              val.medicalRecordNo = this.medicalRecordNo
              val.id = item.id
              arr[index].push(val)
            })
          }
        })
        console.log(arr)
        arr.forEach((item) => {
          let obj1 = {
            purpose: '',
            pillsName: '',
            pillsUsage: '',
            beginDate: '',
            endDate: '',
            medicalRecordNo: this.medicalRecordNo,
            medicalType: '6',
            id: ''
          }
          let count = 0 // 定义计数器
          item.forEach((val, index) => {
            obj1.purpose = val.purpose
            obj1.pillsUsage =
              String(val.pillsUsage) + ' ' + String(val.frequency)
            obj1.beginDate = val.beginDate
            obj1.endDate = val.endDate
            obj1.id = val.id // 为了一会比对删除 重复项

            if (count !== 0 && count % 4 === 0) {
              obj1.pillsName += '\n' // 每遍历4个元素，在当前元素后添加换行符
            }

            obj1.pillsName +=
              String(val.pillsName) + ' ' + String(val.amountPer) + ' '

            count++ // 每遍历一个元素计数器自增1
          })
          this.yaoLiXiaoJieList.summaryTraditionalMedicalRecordList.push(obj1)
        })
        this.medicalOrdersOpen = false
      } else if (type == 7) {
        // 表示药学监护记录页 长嘱临嘱点击了确定
        this.medicalOrdersObj = [
          ...this.medicalOrdersObj1,
          ...this.medicalOrdersObj2
        ]
        let arr = []
        this.medicalOrdersObj.forEach((item) => {
          arr.push(item)
          if (
            item.childMedicalRecordList &&
            item.childMedicalRecordList.length
          ) {
            item.childMedicalRecordList.forEach((val) => {
              arr.push(val)
            })
          }
        })
        console.log(arr)
        console.log(this.medicalOrdersObj)
        // 表示药学监护记录页 长嘱临嘱点击了确定
        arr.forEach((item) => {
          item.medicalRecordNo = this.medicalRecordNo
          item.purpose = '新增'
          this.pharmaceuticalCare.pharmaceuticalCareDetailVoList[
            this.yaoxuejianhuindex
            ].careDetailMedicalList.push(item)
        })
        this.medicalOrdersOpen = false
      } else if (type == 8) {
        // 表示药学监护记录页点击了中药饮片确定按钮
        this.medicalOrdersObj = [...this.medicalOrdersObj3]
        let arr = []
        this.medicalOrdersObj.forEach((item, index) => {
          item.medicalRecordNo = this.medicalRecordNo
          arr[index] = [item]
          if (
            item.childMedicalRecordList &&
            item.childMedicalRecordList.length
          ) {
            item.childMedicalRecordList.forEach((val) => {
              val.medicalRecordNo = this.medicalRecordNo
              val.id = item.id
              arr[index].push(val)
            })
          }
        })
        console.log(arr)
        arr.forEach((item) => {
          let obj1 = {
            purpose: '新增',
            pillsName: '',
            pillsUsage: '',
            beginDate: '',
            endDate: '',
            medicalRecordNo: this.medicalRecordNo,
            id: ''
          }
          let count = 0 // 定义计数器
          item.forEach((val, index) => {
            obj1.purpose = val.purpose ? val.purpose : '新增'
            obj1.pillsUsage =
              String(val.pillsUsage) + ' ' + String(val.frequency)
            obj1.beginDate = val.beginDate
            obj1.endDate = val.endDate
            obj1.id = val.id

            if (index !== 0 && index % 4 === 0) {
              obj1.pillsName += '\n'
            }

            obj1.pillsName +=
              String(val.pillsName) + ' ' + String(val.amountPer) + ' '

            count++ // 每遍历一个元素计数器自增1
          })

          this.pharmaceuticalCare.pharmaceuticalCareDetailVoList[
            this.yaoxuejianhuzhongyaoindex
            ].traditionalMedicalList.push(obj1)
        })

        this.medicalOrdersOpen = false
      } else if (type == 9) {
        // 表示药学监护记录页 出院用药 西药点击了确定
        this.medicalOrdersObj = [
          ...this.medicalOrdersObj1,
          ...this.medicalOrdersObj2
        ]
        let arr = []
        this.medicalOrdersObj.forEach((item) => {
          arr.push(item)
          if (
            item.childMedicalRecordList &&
            item.childMedicalRecordList.length
          ) {
            item.childMedicalRecordList.forEach((val) => {
              arr.push(val)
            })
          }
        })
        console.log(arr)
        // return
        arr.forEach((item) => {
          item.medicalRecordNo = this.medicalRecordNo
          item.medicalType = '8'
          this.pharmaceuticalCare.educWestMedicalRecordList.push(item)
        })
        this.medicalOrdersOpen = false
      } else if (type == 10) {
        // 表示药学监护记录页 出院用药 中药点击了确定
        this.medicalOrdersObj = [...this.medicalOrdersObj3]
        let arr = []
        this.medicalOrdersObj.forEach((item, index) => {
          item.medicalType = '9'
          item.medicalRecordNo = this.medicalRecordNo
          arr[index] = [item]
          if (
            item.childMedicalRecordList &&
            item.childMedicalRecordList.length
          ) {
            item.childMedicalRecordList.forEach((val) => {
              val.medicalType = '9'
              val.medicalRecordNo = this.medicalRecordNo
              val.id = item.id
              arr[index].push(val)
            })
          }
        })
        console.log(arr)
        arr.forEach((item) => {
          let obj1 = {
            purpose: '',
            pillsName: '',
            pillsUsage: '',
            beginDate: '',
            endDate: '',
            medicalRecordNo: this.medicalRecordNo,
            medicalType: '9',
            id: ''
          }
          let count = 0 // 定义计数器
          item.forEach((val, index) => {
            obj1.purpose = val.purpose
            obj1.pillsUsage =
              String(val.pillsUsage) + ' ' + String(val.frequency)
            obj1.beginDate = val.beginDate
            obj1.endDate = val.endDate
            obj1.id = val.id // 为了一会比对删除重复项

            if (count !== 0 && count % 4 === 0) {
              obj1.pillsName += '\n' // 每遍历4个元素，在当前元素后添加换行符
            }
            obj1.pillsName +=
              String(val.pillsName) + ' ' + String(val.amountPer) + ' '
            count++ // 每遍历一个元素计数器自增1
          })

          this.pharmaceuticalCare.educTraditionalMedicalRecordList.push(obj1)
        })

        this.medicalOrdersOpen = false
      }
    },
    // 查询HIS医嘱 取消按钮
    medicalOrdersCancel() {
      this.medicalOrdersOpen = false
    },
    // 下载 药历首页
    downMedicationRecord() {
      this.downMedicationRecordLoading = true
      // 先获取有信息没
      medicationRecordGet(this.medicalRecordNo)
        .then((res) => {
          if (res.data.id !== null) {
            console.log(res.data)
            this.$download.get(
              '/workstation/medicationRecord/download/',
              this.medicalRecordNo,
              `${this.form.patientBaseInfoVo.patientName}病历首页.docx`
            )
          } else {
            this.$message({
              message: '请先完善病历信息再试！',
              type: 'warning',
              showClose: true
            })
          }
        })
        .finally((res) => {
          this.downMedicationRecordLoading = false
        })
      this.downMedicationRecordLoading = false
    },

    // 药历首页 结束  结束

    // 药学监护计划引用模板   开始 开始
    // 药学监护计划引用模板按钮
    templateInfo() {
      // 模板类型（0药学监护计划 1出院用药教育）
      this.params.templateType = '0'
      this.params.pageNum = 1
      this.getList()
      this.title = '引用模板'
      this.open = true
    },
    /** 查询工作站模板信息列表 */
    getList() {
      this.loading = true
      listTemplateInfo(this.params).then((response) => {
        this.templateInfoList = response.rows || []
        this.total = response.total
        this.loading = false
      })
    },
    // 取消按钮
    cancel() {
      this.open = false
      // this.reset();
    },
    // 表单重置
    reset() {
      this.templateInfoList = {
        id: undefined,
        templateName: undefined,
        templateContent: undefined,
        templateType: undefined,
        createBy: undefined,
        createTime: undefined,
        updateBy: undefined,
        updateTime: undefined
      }
      this.resetForm('form')
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      if (selection.length == 1) {
        this.dischargePharmacyEducation = selection[0].templateContent
      }
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.open1 = true
      this.disabled = false
      this.title = '添加模板'
      this.templateList = {
        templateName: undefined,
        templateContent: undefined,
        templateType: undefined
      }
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids
      this.$modal
        .confirm('是否确认删除该模板？')
        .then(() => {
          this.loading = true
          return delTemplateInfo(ids)
        })
        .then(() => {
          this.loading = false
          this.getList()
          this.$modal.msgSuccess('删除成功')
        })
        .catch(() => {
        })
        .finally(() => {
          this.loading = false
        })
    },

    // 药学监护计划引用模板   结束 结束

    // 药学监护记录相关   开始 开始
    getYaoXueJianHuList() {
      getPharmaceuticalCare(this.medicalRecordNo).then((response) => {
        if (response.data !== null) {
          response.data.educWestMedicalRecordList = response.data
            .educWestMedicalRecordList.length
            ? response.data.educWestMedicalRecordList
            : []
          response.data.educTraditionalMedicalRecordList = response.data
            .educTraditionalMedicalRecordList.length
            ? response.data.educTraditionalMedicalRecordList
            : []
          if (!response.data.dischargePharmacyEducation) {
            response.data.dischargePharmacyEducation =
              '①随访复查指标;\n②生活方式;\n③用药注意事项;'
          }
          if (response.data.pharmaceuticalCareDetailVoList.length > 0) {
            response.data.pharmaceuticalCareDetailVoList.forEach((item) => {
              item.executiveCondition = item.executiveCondition
                ? item.executiveCondition
                : '(1)病情变化:\n(2)合理用药情况:\n(3)医保费用:\n(4)其他药事管理指标变化:'
              item.careDetailMedicalList &&
              item.careDetailMedicalList?.length > 0
                ? (item.medicationSummaryOption1 = true)
                : ((item.careDetailMedicalList = []),
                  (item.medicationSummaryOption1 = false))
              item.traditionalMedicalList &&
              item.traditionalMedicalList?.length > 0
                ? (item.medicationSummaryOption2 = true)
                : ((item.traditionalMedicalList = []),
                  (item.medicationSummaryOption2 = false))
            })
            this.pharmaceuticalCare.pharmaceuticalCareDetailVoList =
              response.data.pharmaceuticalCareDetailVoList
          } else {
            this.pharmaceuticalCare.pharmaceuticalCareDetailVoList = []
          }
          this.pharmaceuticalCare = response.data
        }
      })
    },
    // 药学监护记录保存按钮
    saveYaoXueJiLv(type) {
      this.pharmaceuticalCare.medicalRecordNo = this.medicalRecordNo
      this.pharmaceuticalCare.pharmaceuticalCareDetailBoList =
        this.pharmaceuticalCare.pharmaceuticalCareDetailVoList
      // 删除HIS用药 为了比对 添加的id  不删除保存失败
      if (
        this.pharmaceuticalCare.pharmaceuticalCareDetailBoList &&
        this.pharmaceuticalCare.pharmaceuticalCareDetailBoList.length > 0
      ) {
        this.pharmaceuticalCare.pharmaceuticalCareDetailBoList.forEach(
          (detail) => {
            detail.signer = this.user // 签名字段
            // 选择了无以后  清空数据
            console.log(detail)
            if (detail.medicationSummaryOption1 == false) {
              detail.careDetailMedicalList = []
            } else {
              detail.careDetailMedicalList.forEach((medical) => {
                console.log(medical)
                delete medical.id
              })
            }
            if (detail.medicationSummaryOption2 == false) {
              detail.traditionalMedicalList = []
            } else {
              detail.traditionalMedicalList.forEach((medical) => {
                console.log(medical)
                delete medical.id
              })
            }
          }
        )
      }
      if (
        this.pharmaceuticalCare.educWestMedicalRecordList &&
        this.pharmaceuticalCare.educWestMedicalRecordList.length > 0
      ) {
        this.pharmaceuticalCare.educWestMedicalRecordList.forEach((item) => {
          delete item.id
        })
      }
      if (
        this.pharmaceuticalCare.educTraditionalMedicalRecordList &&
        this.pharmaceuticalCare.educTraditionalMedicalRecordList.length > 0
      ) {
        this.pharmaceuticalCare.educTraditionalMedicalRecordList.forEach((item) => {
          delete item.id
        })
      }
      if (type == 1) {
        delete this.pharmaceuticalCare.pharmaceuticalCareDetailVoList
        delete this.pharmaceuticalCare.dischargePharmacyEducation
        console.log('yao', this.pharmaceuticalCare)
        addPharmaceuticalCare(this.pharmaceuticalCare).then((response) => {
          this.$modal.msgSuccess('保存成功')
          this.getYaoXueJianHuList()
        })
      } else {
        delete this.pharmaceuticalCare.pharmaceuticalCareDetailVoList
        console.log('yao', this.pharmaceuticalCare)
        addPharmaceuticalCare(this.pharmaceuticalCare).then((response) => {
          this.$modal.msgSuccess('保存成功')
          this.getYaoXueJianHuList()
        })
      }
    },
    // 手动修改监护记录日期  处理入院天数
    getDateHandle(item, index) {
      let day = getJetLag(
        this.pharmaceuticalCare.admissionDate + '',
        item.careDate + '',
        1
      )
      this.pharmaceuticalCare.pharmaceuticalCareDetailVoList[
        index
        ].inHospitalDays = day + 1 || ''
    },
    // 添加记录
    addRecord() {
      this.dateDisable = false
      // 默认添加记录为当前天  并且计算入院天数
      let days = this.pharmaceuticalCare.admissionDate
        ? getJetLag(
          this.pharmaceuticalCare.admissionDate,
          parseTime(this.nowTime, '{y}-{m}-{d}'),
          1
        )
        : ''
      let obj = {
        medicalRecordNo: this.medicalRecordNo,
        // id: this.pharmaceuticalCare.id,
        careDate: parseTime(this.nowTime, '{y}-{m}-{d}'),
        inHospitalDays: days + 1,
        vitalSigns: '', // 生命体征
        executiveCondition:
          '(1)病情变化:\n(2)合理用药情况:\n(3)医保费用:\n(4)其他药事管理指标变化:', // 监护执行计划
        // schemeAdjustment: "",
        carePlanAdjustment: '',
        careDetailMedicalList: [],
        traditionalMedicalList: [],
        medicationSummaryOption3: 'false',
        pillsEducationOption: 'false'
      }
      this.pharmaceuticalCare.pharmaceuticalCareDetailVoList.push(obj)
    },
    // 删除记录
    delRecord() {
      this.pharmaceuticalCare.pharmaceuticalCareDetailVoList.pop()
    },
    // 删除记录一项
    delRecordOne(row, index) {
      this.$confirm('确认删除当前监护记录吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          console.log(row.id)
          if (row.id) {
            removePharmaceuticalCare(row.id).then((res) => {
              console.log(res)
              this.getYaoXueJianHuList()
            })
          } else {
            this.pharmaceuticalCare.pharmaceuticalCareDetailVoList.splice(
              index,
              1
            )
          }
          this.$message({
            type: 'success',
            message: '删除成功!'
          })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },
    // 下载出院用药教育
    downpharmaceuticalCareDetailVoList() {
      this.downpharmaceuticalCareDetailVoListLoading = true
      // 先获取有信息没
      getPharmaceuticalCare(this.medicalRecordNo)
        .then((res) => {
          if (res.data !== null) {
            this.$download.get(
              '/workstation/pharmaceuticalCare/download/',
              this.medicalRecordNo,
              `${this.form.patientBaseInfoVo.patientName}出院用药教育.docx`
            )
          } else {
            this.$message({
              message: '请先完善出院用药教育再试！',
              type: 'warning',
              showClose: true
            })
          }
        })
        .finally((res) => {
          this.downpharmaceuticalCareDetailVoListLoading = false
        })
      this.downpharmaceuticalCareDetailVoListLoading = false
    },
    // 下载药学监护记录
    downpharmaceuticalCare() {
      this.downpharmaceuticalCareLoading = true
      // 先获取有信息没
      getPharmaceuticalCare(this.medicalRecordNo)
        .then((res) => {
          if (res.data !== null) {
            this.$download.get(
              '/workstation/pharmaceuticalCare/export/',
              this.medicalRecordNo,
              `${this.form.patientBaseInfoVo.patientName}药学监护记录.docx`
            )
          } else {
            this.$message({
              message: '请先完善药学监护记录再试！',
              type: 'warning',
              showClose: true
            })
          }
        })
        .finally((res) => {
          this.downpharmaceuticalCareLoading = false
        })
      this.downpharmaceuticalCareLoading = false
    },
    // 出院教育引用模板
    useEducation() {
      // 模板类型（0药学监护计划 1出院用药教育）
      this.params.templateType = '1'
      this.params.pageNum = 1
      this.getList()
      this.title = '引用模板'
      this.open = true
    },
    /** 查看按钮操作 */
    handleUpdate(row) {
      this.disabled = true
      this.templateList = row
      this.open1 = true
      this.title = '查看模板详情'
    },
    // 表格确定按钮
    useTemplate() {
      this.pharmaceuticalCare.dischargePharmacyEducation =
        this.dischargePharmacyEducation
      this.open = false
    },
    /** 新增模板确定按钮 */
    submitForm(type) {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          this.templateList.id = ''
          this.templateList.templateType = type
          this.buttonLoading = true
          if (this.title == '查看模板详情') {
            // 此时点击确定是为了引用  赋值
            if (type == '0') {
              this.form.medicalGuardianSchedule =
                this.templateList?.templateContent
              this.cancel1()
              this.cancel()
              this.buttonLoading = false
            } else if (type == '1') {
              this.pharmaceuticalCare.dischargePharmacyEducation =
                this.templateList?.templateContent
              this.cancel1()
              this.cancel()
              this.buttonLoading = false
            }
          } else {
            addTemplateInfo(this.templateList)
              .then((response) => {
                this.$modal.msgSuccess('新增成功')
                this.templateList = {
                  templateName: undefined,
                  templateContent: undefined,
                  templateType: undefined
                }
                this.open1 = false
                this.getList()
              })
              .finally(() => {
                this.buttonLoading = false
              })
          }
        }
      })
    },
    // 取消
    cancel1() {
      this.open1 = false
    },
    //  确定并引用按钮
    enterUse(type) {
      if (type == '0') {
        this.submitForm(type)
        // 药历首页药学监护计划模板
        this.form.medicalGuardianSchedule = this.templateList?.templateContent
        this.cancel1()
        this.cancel()
      } else if (type == '1') {
        this.submitForm(type)
        // 出院用药教育模板
        this.pharmaceuticalCare.dischargePharmacyEducation =
          this.templateList?.templateContent
        this.cancel1()
        this.cancel()
      }
    },

    // 药学监护记录相关   结束 结束

    // 药历小结信息   开始 开始
    // 查询该患者药历小结详细信息
    getYaoLiXiaoJieList() {
      getMedicationSummary(this.medicalRecordNo).then((response) => {
        console.log('[ 查询该患者药历小结详细信息 ] >', response)
        if (response.data !== null) {
          // 这一步是判断有无合理用药情况
          response.data.medicationSummaryOption = response.data
            .reasonableMedicationSummary
            ? true
            : false
          this.yaoLiXiaoJieList = response.data
          // 这里计算入院天数
          // 这一步是获取出院时间  没有就取当前时间
          let date = this.form.patientBaseInfoVo.dischargeTime
            ? parseTime(
              this.form.patientBaseInfoVo.dischargeTime,
              '{y}-{m}-{d}'
            )
            : parseTime(this.nowTime, '{y}-{m}-{d}')
          this.yaoLiXiaoJieList.inHospitalDays = this.yaoLiXiaoJieList
            .inHospitalDays
            ? this.yaoLiXiaoJieList.inHospitalDays
            : getJetLag(
            parseTime(
              this.form.patientBaseInfoVo.admissionTime,
              '{y}-{m}-{d}'
            ),
            date,
            1
          ) + 1
          // 赋值入院日期
          this.yaoLiXiaoJieList.inHospitalDate = parseTime(
            this.form.patientBaseInfoVo.admissionTime,
            '{y}-{m}-{d}'
          )
          // 赋值出院日期
          this.yaoLiXiaoJieList.outHospitalDate = parseTime(
            this.form.patientBaseInfoVo.dischargeTime,
            '{y}-{m}-{d}'
          )
          this.yaoLiXiaoJieList.medicalRecordVoList = response.data
            .medicalRecordVoList
            ? response.data.medicalRecordVoList
            : []
          this.yaoLiXiaoJieList.traditionalDiagnosisVoList = response.data
            .traditionalDiagnosisVoList
            ? response.data.traditionalDiagnosisVoList
            : []
        }
      })
    },
    // 中医诊断  添加一行按钮
    addTraditionalDiagnosisVoList(type) {
      if (type == 1) {
        let obj = {
          medicalRecordNo: this.medicalRecordNo,
          illnessName: '',
          patternOfSyndrome: '',
          useType: '1' // 用途类型（0药历首页 1药历小结）
        }
        this.yaoLiXiaoJieList.traditionalDiagnosisVoList.push(obj)
      } else {
        let obj = {
          medicalRecordNo: this.medicalRecordNo,
          illnessName: '',
          patternOfSyndrome: '',
          useType: '0' // 用途类型（0药历首页 1药历小结）
        }
        this.form.traditionalDiagnosisVoList.push(obj)
      }
    },
    // 中医诊断  删除按钮
    delTraditionalDiagnosisVoList(row, index, type) {
      if (type == 1) {
        this.yaoLiXiaoJieList.traditionalDiagnosisVoList.splice(index, 1)
      } else {
        this.form.traditionalDiagnosisVoList.splice(index, 1)
      }
    },
    // 住院期间治疗药物汇总 添加一行按钮
    addMedicalRecordBoList(type, index) {
      if (type == 3) {
        let obj = {
          medicalRecordNo: this.medicalRecordNo,
          pillsName: '',
          amountPer: '',
          pillsUsage: '',
          frequency: '',
          beginDate: '',
          endDate: '',
          medicalType: '3' // 用药类型（0现病史 1既往病史 2初始药物治疗 3药历小结 4药品医嘱 5初始饮片 6小结饮片）
        }
        this.yaoLiXiaoJieList.medicalRecordVoList.push(obj)
      } else if (type == 2) {
        let obj = {
          medicalRecordNo: this.medicalRecordNo,
          pillsName: '',
          amountPer: '',
          pillsUsage: '',
          frequency: '',
          beginDate: '',
          endDate: '',
          medicalType: '2' // 用药类型（0现病史 1既往病史 2初始药物治疗 3药历小结 4药品医嘱 5初始饮片 6小结饮片）
        }
        this.form.initalMedicalRecordVoList.push(obj)
      } else if (type == 5) {
        // 表示药历页  中药饮片点击添加一行
        let obj = {
          medicalRecordNo: this.medicalRecordNo,
          pillsName: '',
          pillsUsage: '',
          beginDate: '',
          medicalType: '5' // 用药类型（0现病史 1既往病史 2初始药物治疗 3药历小结 4药品医嘱 5初始饮片 6小结饮片）
        }
        this.form.initTraditionalMedicalList.push(obj)
        this.$forceUpdate()
      } else if (type == 6) {
        // 表示药历小结页  中药饮片点击添加一行
        let obj = {
          medicalRecordNo: this.medicalRecordNo,
          pillsName: '',
          pillsUsage: '',
          beginDate: '',
          endDate: '',
          medicalType: '6' // 用药类型（0现病史 1既往病史 2初始药物治疗 3药历小结 4药品医嘱 5初始饮片 6小结饮片）
        }
        this.yaoLiXiaoJieList.summaryTraditionalMedicalRecordList.push(obj)
        this.$forceUpdate()
      } else if (type == 7) {
        // 表示药学监护记录页  出院用药 西药点击添加一行
        let obj = {
          medicalRecordNo: this.medicalRecordNo,
          pillsName: '',
          amountPer: '',
          pillsUsage: '',
          frequency: '',
          pillsCycle: '',
          medicalType: '8' // 用药类型（0现病史 1既往病史 2初始药物治疗 3药历小结 4药品医嘱 5初始饮片 6小结饮片 7出院用药 8教育用药 9教育用药中药饮片）
        }
        this.pharmaceuticalCare.educWestMedicalRecordList.push(obj)
        this.$forceUpdate()
      } else if (type == 8) {
        // 表示药学监护记录页  药物治疗方案调整点击添加一行
        let obj = {
          medicalRecordNo: this.medicalRecordNo,
          purpose: '新增', // 用药调整
          pillsName: '', // 药物名称
          amountPer: '', // 单次剂量
          pillsUsage: '',
          frequency: '',
          beginDate: '',
          pillsCycle: '' // 备注字段
        }
        this.pharmaceuticalCare.pharmaceuticalCareDetailVoList[
          index
          ].careDetailMedicalList.push(obj)
      } else if (type == 9) {
        // 表示药学监护记录页  药物治疗方案 中药表格 点击添加一行
        let obj = {
          medicalRecordNo: this.medicalRecordNo,
          purpose: '新增',
          pillsName: '',
          pillsUsage: '',
          beginDate: ''
        }
        this.pharmaceuticalCare.pharmaceuticalCareDetailVoList[
          index
          ].traditionalMedicalList.push(obj)
      } else if (type == 10) {
        // 表示药学监护记录页  出院用药 中药饮片点击添加一行
        let obj = {
          medicalRecordNo: this.medicalRecordNo,
          pillsName: '',
          pillsUsage: '',
          endDate: '',
          pillsCycle: '',
          medicalType: '9' // 用药类型（0现病史 1既往病史 2初始药物治疗 3药历小结 4药品医嘱 5初始饮片 6小结饮片 7出院用药 8教育用药 9教育用药中药饮片）
        }
        this.pharmaceuticalCare.educTraditionalMedicalRecordList.push(obj)
        this.$forceUpdate()
      }
    },
    // 递归删除方法
    deleteRecordFromComplexArray(arr, recordId) {
      // 遍历数组中的每一项
      for (let i = 0; i < arr.length; i++) {
        const item = arr[i]
        // 如果某一项是一个数组，则递归调用本函数来处理该子数组
        if (Array.isArray(item)) {
          this.deleteRecordFromComplexArray(item, recordId)
        }
        // 如果某一项是一个医疗记录对象，并且该对象的 ID 匹配要删除的记录 ID，则将其从数组中删除
        else if (item.id === recordId) {
          arr.splice(i, 1)
          console.log('已删除记录：', recordId)
          break
        }
        // 如果某一项是一个医疗记录对象，但是其 ID 不匹配要删除的记录 ID，则将其 childMedicalRecordList 属性作为子数组来递归调用本函数
        else if (Array.isArray(item.childMedicalRecordList)) {
          this.deleteRecordFromComplexArray(
            item.childMedicalRecordList,
            recordId
          )
        }
      }
    },

    // 住院期间治疗药物汇总 删除按钮
    delMedicalRecordBoList(row, index, type, _index) {
      if (type == 3) {
        // 调用函数来删除医疗记录 ID
        this.yaoLiXiaoJieList.medicalRecordVoList.splice(index, 1)
      } else if (type == 2) {
        //  删除药历初始用药表格
        this.form.initalMedicalRecordVoList.splice(index, 1)
      } else if (type == 5) {
        //  删除药历中药饮片 表格
        this.form.initTraditionalMedicalList.splice(index, 1)
        this.$forceUpdate()
      } else if (type == 6) {
        //  删除药历小结中药饮片 表格
        this.yaoLiXiaoJieList.summaryTraditionalMedicalRecordList.splice(
          index,
          1
        )
        this.$forceUpdate()
      } else if (type == 7) {
        //  删除药学监护记录 西药 表格
        this.pharmaceuticalCare.educWestMedicalRecordList.splice(index, 1)
        // this.$forceUpdate();
      } else if (type == 8) {
        //  删除药学监护记录药物治疗方案调整 表格
        this.pharmaceuticalCare.pharmaceuticalCareDetailVoList[
          _index
          ].careDetailMedicalList.splice(index, 1)
        // this.$forceUpdate();
      } else if (type == 9) {
        //  删除药学监护记录药物治疗方案调整 中药饮片表格
        this.pharmaceuticalCare.pharmaceuticalCareDetailVoList[
          _index
          ].traditionalMedicalList.splice(index, 1)
        // this.$forceUpdate();
      } else if (type == 10) {
        //  删除药学监护记录 中药 表格
        this.pharmaceuticalCare.educTraditionalMedicalRecordList.splice(
          index,
          1
        )
      }
    },
    // 药学小结信息保存按钮
    saveYaoLiXiaoJie() {
      this.yaoLiXiaoJieList.signer = this.user
      console.log(this.yaoLiXiaoJieList)
      // 这一步是判断有无合理用药情况
      this.yaoLiXiaoJieList.medicationSummaryOption
        ? ' '
        : (this.yaoLiXiaoJieList.reasonableMedicationSummary = '')
      this.yaoLiXiaoJieList.medicalRecordNo = this.medicalRecordNo
      this.yaoLiXiaoJieList.medicalRecordBoList =
        this.yaoLiXiaoJieList.medicalRecordVoList
      this.yaoLiXiaoJieList.traditionalDiagnosisBoList =
        this.yaoLiXiaoJieList.traditionalDiagnosisVoList
      delete this.yaoLiXiaoJieList.medicalRecordVoList
      delete this.yaoLiXiaoJieList.traditionalDiagnosisVoList
      if (
        this.yaoLiXiaoJieList.summaryTraditionalMedicalRecordList &&
        this.yaoLiXiaoJieList.summaryTraditionalMedicalRecordList.length > 0
      ) {
        this.yaoLiXiaoJieList.summaryTraditionalMedicalRecordList.forEach(
          (item) => {
            delete item.id
          }
        )
      }
      if (
        this.yaoLiXiaoJieList.medicalRecordBoList &&
        this.yaoLiXiaoJieList.medicalRecordBoList.length > 0
      ) {
        this.yaoLiXiaoJieList.medicalRecordBoList.forEach((item) => {
          delete item.id
        })
      }
      addMedicationSummary(this.yaoLiXiaoJieList).then((res) => {
        this.$modal.msgSuccess('保存成功')
        this.getYaoLiXiaoJieList()
      })
    },
    // 下载药学监护小结
    downyaoLiXiaoJieList() {
      this.downyaoLiXiaoJieListLoading = true
      // 先获取有信息没
      getMedicationSummary(this.medicalRecordNo)
        .then((res) => {
          if (res.data !== null) {
            this.$download.get(
              '/workstation/medicationSummary/export/',
              this.medicalRecordNo,
              `${this.form.patientBaseInfoVo.patientName}药历小结.docx`
            )
          } else {
            this.$message({
              message: '请先完善药历小结信息再试！',
              type: 'warning',
              showClose: true
            })
          }
        })
        .finally((res) => {
          this.downyaoLiXiaoJieListLoading = false
        })
      this.downyaoLiXiaoJieListLoading = false
    },

    // 药历小结信息  结束 结束

    // 左侧菜单激活面板
    handleChange(val) {
      let arr = ['1', '2', '3', '4', '5']
      if (val.length > 0) {
        // 清除设置的上边距
        this.$refs.rightBox.style.top = 0
        this.activeCard = [...val[val.length - 1]]
        console.log(this.activeCard)
        if (val.includes('2')) {
          this.$refs.box.scrollIntoView({
            behavior: 'smooth',
            block: 'start',
            inline: 'start'
          })
        }
        // 用药时间轴
        if (val.includes('3')) {
          this.$refs.yongyaoshijianzhou.getList()
        }
        // 药学监护记录
        if (val.includes('4')) {
          // 先获取药学监护记录详细信息
          this.getYaoXueJianHuList()
          this.$refs.box.scrollIntoView({
            behavior: 'smooth',
            block: 'start',
            inline: 'start'
          })
        }
        // 药历小结
        if (val.includes('5')) {
          // 先获取药历小结详细信息
          this.getYaoLiXiaoJieList()
        }
      }
    },
    /** 查询科室下拉树结构 */
    getDeptTree() {
      deptTreeSelect().then((response) => {
        this.deptOptions = response.data
      })
    }
  }
}
</script>

<style lang="scss" scoped>
::v-deep .chushiyaowuzhenliao {
  .cell {
    display: flex;
    align-items: center;
  }
}

/* 隐藏多选框 */
::v-deep .disabled-column .el-checkbox__input {
  display: none;
}

::v-deep .el-dialog__body {
  max-height: 750px !important;
  overflow: auto;
}

.buliangshihao {
  ::v-deep .el-input__inner {
    border: none;
    border-radius: 0px;
    border-bottom: 1px solid #000;
  }

  //checkBox自定义禁用样式
  .el-checkbox__input.is-disabled + .el-checkbox__label {
    color: #808080 !important;
  }

  .el-checkbox__input.is-disabled.is-checked + .el-checkbox__label {
    color: #1890ff !important;
  }

  .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner {
    background-color: #1890ff !important;
    border-color: #1890ff !important;
  }

  //输入框 还有 textarea 禁用状态下颜色改变
  ::v-deep .el-input.is-disabled .el-input__inner,
  textarea:disabled {
    color: #606266;
    background-color: white;
  }
}

.label {
  ::v-deep .el-form-item__label {
    font-size: 14px;
    color: #aaaaaa;
    font-weight: normal;
  }
}

.label1 {
  ::v-deep .el-form-item__label {
    font-size: 16px;
    font-weight: normal;
    color: #000;
  }
}

.yaoxuejianhu {
  table tr th {
    border-right: 1px solid #ccc !important;
    border-bottom: 1px solid #ccc !important;
  }

  table tr th:last-child {
    border-right: none !important;
  }

  table tr td {
    // border-top: 1px solid #ccc !important;
    border-right: 1px solid #ccc !important;
    border-bottom: 1px solid #ccc !important;
  }

  table tr td:last-child {
    border-right: none !important;
  }
}

::v-deep .el-collapse-item__header {
  font-family: "Arial Negreta", "Arial Normal", "Arial", sans-serif;
  font-weight: 700;
  font-style: normal;
  font-size: 16px;
  text-align: center;
  height: 65px;
  padding-left: 55px;
  border: 1px solid rgba(242, 242, 242, 1);
  margin-top: 20px;
}

::v-deep .el-collapse-item__wrap {
  border: none;
}

::v-deep .el-collapse {
  border: none;
}

::v-deep .el-radio__label {
  padding-left: 7px;
}

::v-deep .el-radio {
  margin-right: 10px;
}

table > tr > th > div {
  font-weight: normal;
}

table > tr > th {
  padding: 6px;
}

table > tr > td {
  padding: 6px;
}

.input {
  width: 100%;
  padding: 5px 10px;
  font-family: "Arial Normal", "Arial", sans-serif;
  font-weight: 400;
  font-style: normal;
  font-size: 13px;
  letter-spacing: normal;
  color: #000000;
  vertical-align: none;
  text-align: left;
  text-transform: none;
  background-color: transparent;
  border-color: transparent;
  resize: none;
  border: 1px solid #dcdfe6;
  border-radius: 15px;
}

.value {
  display: inline-block;
  min-width: 60px;
  border-bottom: 1px solid #000;
  text-align: center;
  line-height: 30px;

  ::v-deep .vue-treeselect--disabled .vue-treeselect__control {
    border: none;
    background-color: #fff;
    display: flex;
    height: 30px;
  }

  ::v-deep .vue-treeselect__control-arrow-container {
    display: none;
  }

  ::v-deep .vue-treeselect {
    text-align: center;
  }
}

.headTxt {
  font-size: 18px;
  font-weight: 900;
  // margin-left: 19px;
}

table {
  border-collapse: collapse !important;
  border-color: #ccc !important;
  table-layout: fixed;
}

.el-textarea .el-input--medium {
  width: 100%;
}
</style>
